Yoast SEO
[Plugin: WordPress SEO by Yoast] SEO Description not working (3 posts)

  1. k0k1man
    Posted 3 years ago #

    The description is not appearing on posts or categories. I looked into the theme's source and did not see any meta name="description"

    How do I call the Yoast SEO description from header.php ?

    Thank you


  2. James Mehorter
    Posted 3 years ago #

    @k0k1man, any luck with this?

    I don't use wp_head() in my theme so I'm looking for a template function to display the Yoast page description / keywords within my header.php file.


    EDIT: Found that the yoast plugin simply stores the values in postmeta, so this solution is working perfect for my use. I've placed the following within my <head></head> tags.

    	//Grab the page seo settings
    	$metadesc = get_post_meta($post->ID, '_yoast_wpseo_metadesc', true);
    	$metakeywords = get_post_meta($post->ID, '_yoast_wpseo_metakeywords', true);
    <?php if(!empty($metadesc)) : ?><meta name="description" content="<?php echo $metadesc ?>" /><?php endif ?>
    <?php if(!empty($metakeywords)) : ?><meta name="keywords" content="<?php echo $metakeywords ?>" /><?php endif ?>

    Hope that helps someone else.

  3. Joy
    Posted 3 years ago #

    The plugin is pulling whatever is the first tag in the post for the description. I have a page with a gallery, so the first tag happens to be a <style> tag so that's what I'm seeing as the meta description and the opengraph description.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yoast SEO
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic