WP Facebook Open Graph protocol
[resolved] When Using Excerpts og:description Shows the Read More (5 posts)

  1. Butternut Valley Farm
    Posted 4 years ago #

    I use manual excerpts to avoid content duplication on Category pages, among other things. When you do manual excerpts, a small hack is usually needed in the functions file in order to display the Read More at the end of the excerpt. I use this:

    function manual_excerpt_more($excerpt) {
    $excerpt_more = '';
    if( has_excerpt() ) {
    $excerpt_more = ' ... <a href="'.get_permalink().'">Read More &raquo;</a>';
    return $excerpt . $excerpt_more;
    add_filter('get_the_excerpt', 'manual_excerpt_more');

    Works great. Trouble is that "... Read More ยป" is appearing in the og:description

    Any ideas?


  2. Chuck Reynolds
    Plugin Author

    Posted 4 years ago #

    by doing that you're making it part of the excerpt thereby pulling it into the og:desc. I don't see a way to scrub that as everybody's functions would be named differently. No way to get around that.

  3. Butternut Valley Farm
    Posted 4 years ago #

    Could it just be hacked with a regular expression match and strip? I guess on line 105?

    echo "\t<meta property='og:description' content='".esc_attr(strip_tags(get_the_excerpt($post->ID)))."' />\n";

    Forgive me, I'm not a php coder, but something like this (in Perl)?

    $description = esc_attr(strip_tags(get_the_excerpt($post->ID)));
    if ($description =~ /.*Read More$/) {
      $description =~ s/
      echo the stripped excerpt;
    else { echo the original excerpt;
  4. Chuck Reynolds
    Plugin Author

    Posted 4 years ago #

    if every wordpress install in the world always and forever used "read more" then sure. Even with the small amount of ppl said to be using the plugin I know I already have users in South America and Canada aside from the US users... different languages, styles, etc... anybody can change that so a regexp or pregmatch wouldn't work.

  5. Butternut Valley Farm
    Posted 4 years ago #

    Thanks Chuck, I understand, and thank you again for your plugin. I wasn't suggesting a modification on your end necessarily. I do believe that some flavor of Read More in manual excerpts is pretty common, and should probably be broken out as a global var, preferably in WP, but if not then in plugins which deal with excerpts. I was really just confirming that line was where I'd hack your code with my own regex. And not being a PHP coder, I was sort of fishing for some code hints :) Anyway, thanks again for your personal responses on all these threads.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Facebook Open Graph protocol
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic