WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
[resolved] [Plugin: WordPress SEO] Using SEO Title and Meta Description in wp Loop (11 posts)

  1. Ralf Skirr
    Member
    Posted 3 years ago #

    How can I display SEO Title and Metadescription from the plugin inside the loop?

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. Ralf Skirr
    Member
    Posted 3 years ago #

    Did some research and figured it out myself. :)

    <?php echo get_post_meta($post->ID, '_yoast_wpseo_title', true); ?>

    And for the description it would be:

    <?php echo get_post_meta($post->ID, '_yoast_wpseo_metadesc', true); ?>

  3. Joost de Valk
    Member
    Plugin Author

    Posted 3 years ago #

    Absolutely true :)

  4. Ralf Skirr
    Member
    Posted 3 years ago #

    Oh, I guess we need to take it a step further.

    I installed the plugin to a wp that already has posts.

    Using the code above it does not output any title for older posts; it only outputs titles for posts that i saved after installing the wordpress seo plugin.

    Is this how it is supposed to work?

    If yes, maybe the code above should be used in some if else statement.

    Something like:
    if there is a yoast seo title display that
    else display wp_title

    Ah, now you can see, I'm not a programmer. Would be nice if anybody could provide the php code.

  5. Joost de Valk
    Member
    Plugin Author

    Posted 3 years ago #

    Well, you're hooking into the stored title now, you could also hook into the title function itself, try this:

    echo $wpseo_front->title();

  6. Ralf Skirr
    Member
    Posted 3 years ago #

    When I use it as is, i get the error message:

    Warning: Missing argument 1 for WPSEO_Frontend::title(),

    When i enter something like this:
    <?php echo $wpseo_front->title($postID);?> (random trial of mine)

    It works on single pages, but not on index pages.

    On index pages each entry gets the title of the index page it is displayed on, not the title for the post id of the looped element.

  7. Joost de Valk
    Member
    Plugin Author

    Posted 3 years ago #

    Why do you want to use this title on those pages too? It just doesn't make much sense to me I guess :)

  8. Ralf Skirr
    Member
    Posted 3 years ago #

    The idea is to create a custom read more link after excerpts. :)

  9. Joost de Valk
    Member
    Plugin Author

    Posted 3 years ago #

    to make it work for you i'd have to apply a fix that I don't really want to as it'd use more memory... Sorry.

  10. Michael
    Member
    Posted 3 years ago #

    <?php echo get_post_meta($post->ID, '_yoast_wpseo_title', true); ?>
    <?php echo get_post_meta($post->ID, '_yoast_wpseo_metadesc', true); ?>

    Are just what I am looking for !!!

    What would be the PHP code for meta-keywords? =)

  11. Michael
    Member
    Posted 3 years ago #

    I found the answer on my own ..

    The code I was looking for to pull the meta keywords is ..
    <?php echo get_post_meta($post->ID, '_yoast_wpseo_metakeywords', true); ?>

    Hope this helps someone.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic