Support » Plugin: Yoast SEO » [Plugin: WordPress SEO by Yoast] Meta Descriptions on Page

  • I have a weird request…

    I have a client that I am running a site for and they wanted a page that, in a certain area of the page, pulled the most recent post in a certain category. They are now asking to pull the META DESCRIPTION that they wrote for the post in the YOAST SEO meta description field and display it right below the post title, and then have a read more link after that.

    Is this possible? Here is the code I have so far to pull the title of the most recent post from a category and display it in an area of a page.

    <?php
    global $post;
    $myposts = get_posts('numberposts=1&category=18&order=DESC');
    foreach($myposts as $post) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

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

Viewing 1 replies (of 1 total)
  • You can use the following line of code (inside the post loop) to display the current posts meta description as set in the WordPress SEO plugin;

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

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] Meta Descriptions on Page’ is closed to new replies.