• 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

Viewing 13 replies - 1 through 13 (of 13 total)
  • Did you take them out again, because I don’t even see them on your website?

    Thread Starter hays298

    (@hays298)

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

    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(); ?>">

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

    Thread Starter hays298

    (@hays298)

    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 https://hayleysummers.com/2014/04/23/how-to-live-with-excitement/
    og:url https://hayleysummers.com/how-to-live-with-excitement/
    301 https://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)

    Try this instead:

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

    Thread Starter hays298

    (@hays298)

    With this I get this error:

    Object Invalid Value Object at URL ‘https://hayleysummers.com/2014/04/23/how-to-live-with-excitement/&#8217; 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!

    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.

    Thread Starter hays298

    (@hays298)

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

    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.

    Thread Starter hays298

    (@hays298)

    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.

    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; ?>
    Thread Starter hays298

    (@hays298)

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

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Open Graph tags for Facebook’ is closed to new replies.