WordPress.org

Ready to get started?Download WordPress

Forums

All in One SEO and Opengraph Meta for Facebook like button (7 posts)

  1. tushonline
    Member
    Posted 2 years ago #

    Hello
    I am trying to add Opengraph meta data in head of the blog to use Facebook like button.

    So that each post can carry its own title, description, image.

    Everything is working fine but just not been able to catch meta description which is generated / added for All in One SEO plugin.

    Which function should I call from this plugin to echo correct description for each post?

  2. photocurio
    Member
    Posted 2 years ago #

    yup, I'd like to know also. I've tried adding a description tag directly to the header with such php as this:

    <?php if ( is_single() ) echo '<meta property="og:description" content="' ;?>
    <?php if ( is_single() ) the_excerpt() ;?>
    <?php if ( is_single() ) echo '" />' ;?>

    but I think my syntax is incorrect. Anyone want to suggest a fix to my code?

  3. photocurio
    Member
    Posted 2 years ago #

    I also tried combining this into a single statement:
    <?php if ( is_single() ) echo '<meta property="og:description" content="' ; echo ( the_excerpt() ) ; echo '" />' ; ?>

    doesn't work. the_excerpt seems to add lots more stuff than just the excerpt.

  4. photocurio
    Member
    Posted 2 years ago #

    this all is more complex than I thought. This code (from 2008?) worked!

    WordPress: Dynamic Meta Description and Keywords howto

    Quoted here:

    <meta name="description" content="
    <?php if (have_posts() && is_single() OR is_page()):while(have_posts()):the_post();
    $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", get_the_excerpt());
    echo apply_filters('the_excerpt_rss', $out_excerpt);
    endwhile;
    elseif(is_category() OR is_tag()):
    if(is_category()):
    echo "Posts related to Category:
    ".ucfirst(single_cat_title("", FALSE));
    elseif(is_tag()):
    echo "Posts related to Tag:
    ".ucfirst(single_tag_title("", FALSE));
    endif;
    else: ?>
    ADD HERE YOUR DEFAULT DESCRIPTION
    <?php endif; ?>" />
  5. photocurio
    Member
    Posted 2 years ago #

    The above works, but if someone knows of a way to get the excerpt into the meta tag WITHOUT creating an additional loop, that would be nice. Anyone out there?

  6. mtnporcupine
    Member
    Posted 2 years ago #

    I am also having this problem. I was hoping that this plugin would pull in the excerpt for og:description, but no luck. Anybody have a suggestions besides the extra loop?

  7. kk4uga
    Member
    Posted 2 years ago #

    Same issue here. Found this and it works:

    <meta property="og:description" content="<?php echo get_post_meta($post->ID, '_aioseop_description', true); ?>" />

Topic Closed

This topic has been closed to new replies.

About this Topic