[Resolved] Google indexes the posts with the picture caption as the description

Home Forums Support Google indexes the posts with the picture caption as the description

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #312174
    Iñigo García Aldazabal

    Hello again.
    Wordpress does not allow the picture caption of featured images to appear. But I needed it and changed the design of the posts:
    In content, first again the featured image – now it shows captions – and then the text and more images.
    Issue?
    Now Google indexes the pages with a horrible look: the title of the post and in the description the picture caption and the signature of the author of the photograph.
    I have searched and searched the internet and found a single reference to two possible solutions.
    First, include the following code in the header.php:

    <Meta name = “description” content = “<? Php echo get_the_excerpt ();?>” /> ‘

    Second, include the following code that generates a description field in each posts:

    <? Php
      If ((is_single ()) && (has_excerpt ())) {
        $ D = get_the_excerpt ();
      } Elseif (is_page ()) {
        $ D = get_post_meta (get_the_ID (), ‘desc’, true);
      }
      If ($ d) {
        $ D = preg_replace (“/<.*?>/”, “”, $ d);
        Echo ‘<meta name = “description” content = “‘. $ D. ‘” />’;
      }
    ?>

    But I have tried the latter and it does not work at all.

    Any suggestions for Google to correctly index posts?
    I would rather not add more plugins, Yoast style.
    A cordial greeting.

    GeneratePress 1.3.46
    GP Premium 1.2.96
    #312236
    Tom
    Lead Developer
    Lead Developer

    I know you said you don’t want to add Yoast, but it’s really the best option for things like this. There’s a reason it’s used by millions of WordPress website. It will help you achieve exactly what you’re wanting, and will also help in other ways as well (site maps etc..).

    #312249
    Iñigo García Aldazabal

    If you think Yoast is the best option, I’ll think about it. Only that I start to have too many plugins.
    Just one last question. The code:

    <Meta name = “description” content = “<? Php echo get_the_excerpt ();?> “/> ‘

    Do you think it can help?
    If not, I follow your advice and install Yoast.
    Thank you.

    #312251
    Tom
    Lead Developer
    Lead Developer

    That used to be the norm, but these days Google actually grabs the description for you based on what the user searches.

    Doing something like that should work in theory, but I wouldn’t really suggest it:

    <meta name="description" content="<?php echo get_the_excerpt ();?>" />

    Having too many plugins isn’t an issue as long as they’re well coded 🙂

    #312261
    Iñigo García Aldazabal

    Okay. I’ll have to learn how to use Yoast.
    Thank you very much.

    #312263
    Tom
    Lead Developer
    Lead Developer
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.