WordPress.org

Support

Support » Plugins and Hacks » WP Facebook Open Graph protocol » [Resolved] [Plugin: WP Facebook Open Graph protocol] When Using Excerpts og:description Shows the Read More

[Resolved] [Plugin: WP Facebook Open Graph protocol] When Using Excerpts og:description Shows the Read More

  • 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?

    http://wordpress.org/extend/plugins/wp-facebook-open-graph-protocol/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Chuck Reynolds

    @ryno267

    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.

    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/Read More//;
      echo the stripped excerpt;
    }
    else { echo the original excerpt;
    }
    Plugin Author Chuck Reynolds

    @ryno267

    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.

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] [Plugin: WP Facebook Open Graph protocol] When Using Excerpts og:description Shows the Read More’ is closed to new replies.
Skip to toolbar