Strict Standards: Redefining already defined constructor for class bbdb in /home/themes/public_html/forums/bb-includes/db-mysql.php on line 12

Strict Standards: Declaration of BB_Walker_Blank::start_lvl() should be compatible with BB_Walker::start_lvl($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127

Strict Standards: Declaration of BB_Walker_Blank::end_lvl() should be compatible with BB_Walker::end_lvl($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127

Strict Standards: Declaration of BB_Walker_Blank::start_el() should be compatible with BB_Walker::start_el($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127

Strict Standards: Declaration of BB_Walker_Blank::end_el() should be compatible with BB_Walker::end_el($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127
How to: Facebook Open Graph <meta> « ThemeShaper Forums

ThemeShaper Forums » Thematic

[closed]

How to: Facebook Open Graph <meta>

(4 posts)
  • Started 4 years ago by Ben W.
  • Latest reply from sunysky
  • This topic is not a support question
  1. Ben W.
    Member

    If you are using the Facebook “Like” button on your page, you may want to have a better control over it – including an Admin page. (More about Open Graph protocol.)

    You'll need a logo image for your blog and put it to your Thematic /images/ directory, or, if you are using a child theme, to your child themes /images/ directory. Put the following code snippet to your functions.php of Thematic, or, if you are using a child theme, of your child theme:

    (If you need to find out your Facebook ID, click on the "Photos" tab of your FB profile, select your profile photos, and grab the number of the http://www.facebook.com/…&id=YOUR_ID part.)

    /*
     * Facebook Open Graph
     */
    function open_graph($content) {
    	$content .='<meta property="fb:admins" content="YOUR_FACEBOOK_ID" />' . "\n";
    	if (is_home() || is_front_page()) {
    		$url = get_option('home');
    		$title = get_bloginfo('name');
    		$description = get_bloginfo('description');
    		$article = 'blog';
    	} else {
    		global $post;
    		$url = get_permalink($post->ID);
    		$title = get_the_title();
    		$description = get_the_excerpt();
    		$article = 'article';
    	}
    	$content .='<meta property="og:site_name" content="' . get_bloginfo('name') . '" />' . "\n";
    	$content .='<meta property="og:title" content="' . $title . '" />' . "\n";
    	$content .='<meta property="og:description" content="' . $description . '" />' . "\n";
    	$content .='<meta property="og:type" content="' . $article . '" />' . "\n";
    	$content .='<meta property="og:url" content="' . $url . '" />' . "\n";
    	$content .='<meta property="og:image" content="' . get_bloginfo('stylesheet_directory') . '/images/YOUR_LOGO.jpg" />' . "\n";
    	return $content;
    }
    add_filter ('thematic_create_description', 'open_graph');
    
    function open_graph_doctype($content) {
    	$content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
    	$content .= '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
    	return $content;
    }
    apply_filter('thematic_create_doctype', 'open_graph_doctype');

    Please note that the document won't validate as XHTML 1.0 Transitional anymore. Changing it to the required DOCTYPE XHTML + RDFa (<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">) would make it almost like XHTML 1.1, which is Strict, but will easily brake existing forms etc.

    If you are not using a caching solution (like WP Super Cache or Hyper Cache), you could restrict the meta tags to be shown the Facebook crawler only:

    function open_graph($content) {
    	if ($_SERVER['HTTP_USER_AGENT'] == 'facebookexternalhit/1.0 (+http://www.facebook.com/externalhit_uatext.php)') {
    	[the stuff from above]
    	}
    }

    Enjoy!

    Posted 4 years ago #

  2. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 440

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 510

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 512


    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 440

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 510

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 512
    sunysky

    Member

    Hi,

    When I try your solution my wordpress crash and I obtain this error message:

    Fatal error: Call to undefined function apply_filter() in /public_html/photo/wp-content/themes/autofocusplus/functions.php on line 36

    The line 36 is:
    apply_filter('thematic_create_doctype', 'open_graph_doctype');

    I have wordpress 3.0.1 with Autofocus+ theme wich is based on Thematic theme.
    http://fthrwght.com/autofocus/

    Do you know where is the problem?

    Thank you in advance!

    PS: excuse my english, i'm french...

    Posted 4 years ago #

  3. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 440

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 510

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 512


    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 440

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 510

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 512
    Chris

    Moderator

    It should be add_filter.

    Chris

    Posted 4 years ago #

  4. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 440

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 510

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 512


    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 440

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 510

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 512
    sunysky

    Member

    It works!
    Thank a lot Chris! :)

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.


Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GA_Filter::spool_analytics() should not be called statically in /home/themes/public_html/forums/bb-includes/wp-functions.php on line 586

Strict Standards: Non-static method GA_Filter::spool_this() should not be called statically in /home/themes/public_html/forums/my-plugins/googleanalytics.php on line 183