1

Sometimes I start my blog posts by :

  • This is a guest post....
  • This is a sponsored post....
  • [download]This is a download for the post[download]
  • [youtube]this is a video that I put in the begenning[youtube]
  • And I also have a "sharing bar" that appears automatically through a plugin, above my content.

And after that, the actual content of the article.

So when I have the excerpts in the blog listing, I usually see the text that comes first in the post (This is a sponsored post / this is a download...), but what I want to see here is the actual content of the post.

And when something is shared on facebook / twitter / google+ etc., depending on the tags, in the content they will share the same stuff, and even sometimes, the css of the download box, or the counter of the social bar. For example a facebook share : TITLE OF THE ARTICLE : 12 98 67 67 this is a download .download:width:100px;. This is the content. (The counter of the social bar, the download informations, the styling, then the content if I'm lucky)

It's logic, because both the excerpt and social network will grab everything they can, that comes after the

<div class="itemBody>.

How can we change that logic, by specifiying what exactly do we want to consider as "content" ? Is there any plugin or script that would allow to surround the text content, with some kind of tag ?

I know is possible by manually writing the excerpt in the dedicated box, the using yoast SEO (which I have installed) to manually enter the description of each social network, but since I would copy paste the same piece of content, it's a waste of time to have to fill up all these extra fields every time.

So is there an automated solution for that ? (By automated I mean a one shot operation that would allow me to specify what is the actual content) How do the websites that are well optimized for sharing and excerpt displays are handling this subject ?

Thanks !

1

How do the websites that are well optimized for sharing and excerpt displays are handling this subject ?

They definitely have separate fields for excerpt / share-text etc. This is the only way to be certain what text gets used.

These sites also make use of special meta tags in the head to send Facebook, Twitter et al. information about the content that is being shared.

The plugin you mention, Yoast SEO, is a quick way to achieve this functionality. You could also build something yourself with custom Meta Fields, depending on your needs.

On a bunch of my sites I use this code to replace the_excerpt with whatever I fill in at Yoast SEO's meta description field.

/**
 * !Replace the_excerpt with Yoast SEO meta-description
 */
if (function_exists('wpseo_init')){
  add_filter( 'get_the_excerpt', 'wpse_232590_replace_post_excerpt' );
  function wpse_232590_replace_post_excerpt($output)
  {
    $output=get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true);
    return $output;
  }
}

So I fill in the Yoast SEO meta description field and that gets used on my site wherever I use the_excerpt. When you don't want to fill in special content for Twitter and Facebook meta tags you just leave them empty, the meta-description field will be used. So it's just one extra field that you would have to fill in.

  • Allright thanks for the answer. So just to be clear, what you are saying is that you need to manually fill up all these fields (excerpt / facebook meta / twitter meta, etc.), and that this is the only way to go ? (Definitely the best way I understand that for sure, but not the most productive, the description is the same for all of the fields). Is there any existence of a plugin / script, that allows to "surround" the text content we want wordpress to consider as content ? (So yoast SEO and excerpt are taken from here instead of the begenning of the post ?) – Jimmy Gibs Jul 19 '16 at 11:33
  • @JimmyGibs I added a code snippet and some explanation. – Florian Jul 19 '16 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.