WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Meta Descriptions on Page (2 posts)

  1. raptorclick
    Member
    Posted 1 year ago #

    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/

  2. CliffAscent
    Member
    Posted 1 year ago #

    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); ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic