WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
[resolved] W3 Total Cache and Facebook Open Graph Errors (9 posts)

  1. timkainu
    Member
    Posted 2 years ago #

    Hello,

    I am trying to get Facebook to share my post correctly by using Open Graph tags in my header.php file.

    By that, what I mean is when someone clicks the "Like" button on my post, I want the featured image, description and title to show up on the persons page who "Liked" it.

    All I get now is a URL with no description or image.

    When I use the debugger at https://developers.facebook.com/tools/debug/ and input the URL to my article - http://www.timkainu.com/oben-tripod-review/ - it gives me a bunch of errors.

    But when I turn off W3 Total Cache, everything works fine.

    Here are the open graph tags in my header.php file:

    <!-- the default values -->
    <meta property="fb:app_id" content="170151483038653" />
    <meta property="fb:admins" content="1570847387" />
    
    <!-- if page is content page -->
    <?php if (is_single()) { ?>
    <meta property="og:url" content="<?php the_permalink() ?>"/>
    <meta property="og:title" content="<?php single_post_title(''); ?>" />
    <meta property="og:description" content="<?php echo strip_tags(get_the_excerpt($post->ID)); ?>" />
    <meta property="og:type" content="w" />
    <meta property="og:image" content="<?php if (function_exists('wp_get_attachment_thumb_url')) {echo wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID)); }?>" />
    
    <!-- if page is others -->
    <?php } else { ?>
    <meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
    <meta property="og:description" content="<?php bloginfo('description'); ?>" />
    <meta property="og:type" content="website" />
    <meta property="og:image" content="http://www.timkainu.com/wp-content/uploads/2011/11/TimKainu_Default_Image.jpg" /> <?php } ?>

    Please let me know if you need any more info and I'd be glad to supply it.

    Thanks,
    Tim

    http://wordpress.org/extend/plugins/w3-total-cache/

  2. B_Dark
    Member
    Posted 2 years ago #

    @timkainu
    i have the same problem, you find any solution?!?

  3. cyonite
    Member
    Posted 2 years ago #

    timkainu: I see you solved the problem. Was it Total Cache settings or did you miss some FB code?
    Usual problem (I think) seems to be forgetting put the right stuff in the html opening tag.
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:og="http://ogp.me/ns#"
    xmlns:fb="https://www.facebook.com/2008/fbml">

  4. timkainu
    Member
    Posted 2 years ago #

    Well after a week of searching, I found the fix. You have to block W3 Total Cache from serving cached pages to Facebook's bot/crawler. Make sure to reject these user agents in the “page cache” tab in W3 Total Cache:
    ————————-
    facebookexternalhit
    FacebookExternalHit/1.1
    FacebookExternalHit/1.0
    ————————-

    This will block W3 Total Cache from sending cached pages to Facebook. This solved my issue with thumbnails and descriptions.

  5. cyonite
    Member
    Posted 2 years ago #

    Excellent work. Others have had issues as well fun to see you solved it.
    Could you mark this as resolved then?

  6. richardlin
    Member
    Posted 2 years ago #

    @timkainu

    Wow, thanks so much! Problem solved.

  7. Saqib
    Member
    Posted 2 years ago #

    Hi,

    I am also facing the same problem. But when I save the settings, I get this error:
    Disk enhanced page caching is not active. To enable it, add the following rules into the server configuration file (/home/technost/public_html/.htaccess) of the site above the WordPress directives. (View code) Or if permission allow this can be done automatically, by clicking here (auto install).

    I gave 777 permission to htaccess and then tried clicking on auto-install, but still the same message everytime.

    I also manually added the code in htaccess, but still the same message.

    Any guess what's the problem here.

    I am just trying to reject these user agents, just as mentioned by @timkainu
    facebookexternalhit
    FacebookExternalHit/1.1
    FacebookExternalHit/1.0

  8. Frederick Townes
    Member
    Plugin Author

    Posted 2 years ago #

    it's really hard to guess without hands on checking in that release. Can you please submit a bug submission form from the support tab of the plugin?

  9. Saqib
    Member
    Posted 2 years ago #

    Thanks for the reply. Yes, I will submit that form from support tab.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic