WordPress.org

Ready to get started?Download WordPress

Forums

Open Graph tags for Facebook (14 posts)

  1. hays298
    Member
    Posted 3 months ago #

    My WordPress links have just stopped working on Facebook. They were working fine up until a few days ago. I checked them on the Facebook debugger and it comes up with the following warnings:

    The 'og:url' property should be explicitly provided, even if a value can be inferred from other tags.
    The 'og:title' property should be explicitly provided, even if a value can be inferred from other tags.
    The 'og:description' property should be explicitly provided, even if a value can be inferred from other tags.

    I've tried added the following code to my header, but it hasn't made a difference:

    <meta property="og:title" content="<?php get_post; ?>
    <meta property="og:url" content="<?php get_page_link; ?>
    <meta property="og:description" content="<?php the_excerpt(); ?>

    Any ideas?

    Also has anyone come across this before or know why it seems to have suddenly become a problem?

    Links here:

    Website
    Facebook

  2. znuffn
    Member
    Posted 3 months ago #

    Did you take them out again, because I don't even see them on your website?

  3. hays298
    Member
    Posted 3 months ago #

    Yes, I took them out again. I've put them back in case you need to see them.

  4. znuffn
    Member
    Posted 3 months ago #

    Try this:

    <meta property="og:title" content="<?php get_the_title(); ?>">
    <meta property="og:url" content="<?php get_page_link(); ?>">
    <meta property="og:description" content="<?php get_the_excerpt(); ?>">
  5. znuffn
    Member
    Posted 3 months ago #

    Description tag seems to be empty, not sure why, tho.

  6. hays298
    Member
    Posted 3 months ago #

    Awesome. The code you posted has sorted the original error...but now there's a new one:

    Circular Redirect Path: Circular redirect path detected (see Redirect Path section for details).

    Redirect Path
    original http://hayleysummers.com/2014/04/23/how-to-live-with-excitement/
    og:url http://hayleysummers.com/how-to-live-with-excitement/
    301 http://hayleysummers.com/2014/04/23/how-to-live-with-excitement/
    Final URL is in bold (this is the URL we tried to extract metadata from).

    It appears the og url doesn't have the date in it, but the canonical one does. (Both urls work, the one without the date redirects to the one with the date)

  7. znuffn
    Member
    Posted 3 months ago #

    Try this instead:

    <meta property="og:url" content="<?php get_permalink(); ?>">

  8. hays298
    Member
    Posted 3 months ago #

    With this I get this error:

    Object Invalid Value Object at URL 'http://hayleysummers.com/2014/04/23/how-to-live-with-excitement/' of type '' is invalid because the given value '' for property 'og:url' could not be parsed as type 'url'.

    Really appreciating your help with this!

  9. znuffn
    Member
    Posted 3 months ago #

    Oh, you're getting this error because it returns an empty string.

    Maybe this works (I don't run WP so I can't test it):

    <?php if(is_single()){ ?>
    <meta property="og:title" content="<?php get_the_title($post->ID); ?>">
    <meta property="og:url" content="<?php get_permalink($post->ID); ?>">
    <meta property="og:description" content="<?php get_the_excerpt($post->ID); ?>">
    <?php } ?>

    Let me know if that works.

  10. hays298
    Member
    Posted 3 months ago #

    Morning! Same error as the last one with that I'm afraid.

  11. znuffn
    Member
    Posted 3 months ago #

    I'm so sorry, could you give this one more try (again, I can't test it myself):

    <?php if(is_single()){ ?>
    <meta property="og:title" content="<?php echo get_the_title($post->ID); ?>">
    <meta property="og:url" content="<?php echo get_permalink($post->ID); ?>">
    <?php if(has_excerpt($post->ID)){ ?>
    <meta property="og:description" content="<?php echo strip_tags(get_the_excerpt($post->ID)); ?>">
    <?php } ?>
    <?php } ?>

    If the URL is again empty do this instead:

    <meta property="og:url" content="<?php echo (is_ssl() ? 'http' : 'https').'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>">

    And if nothing works, maybe someone else knows how to fix this problem.

  12. hays298
    Member
    Posted 2 months ago #

    I still get this warning in the open graph section:
    The 'og:description' property should be explicitly provided, even if a value can be inferred from other tags.

    However the links now work!

    Thank you so much! I really really appreciate all your help.

  13. znuffn
    Member
    Posted 2 months ago #

    I think this should work now. At least I hope it does. I think I used the wrong function before.

    <?php if(has_excerpt()): ?>
    <meta property="og:description" content="<?php strip_tags(the_excerpt()); ?>">
    <?php endif; ?>
  14. hays298
    Member
    Posted 2 months ago #

    Yes, that works! And even without being able to test it on WordPress - superstar! - thank you so much.

Reply

You must log in to post.

About this Topic