WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to show my meta description content above posts. But i don't know what function I need to call.

Resume: i want to put meta description from Yoast Seo above the posts body.

share|improve this question

closed as off-topic by Mark Kaplun, Johannes Pille, Pieter Goosen, ialocin, s_ha_dum Oct 6 '14 at 23:28

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – Mark Kaplun, Johannes Pille, Pieter Goosen, ialocin, s_ha_dum
If this question can be reworded to fit the rules in the help center, please edit the question.

You will want to make use of Yoast SEO's "WPSEO_Frontend" class. To display the meta description field content, you could do the following:

   if (class_exists('WPSEO_Frontend'))
       echo WPSEO_Frontend::metadesc(false);
share|improve this answer
If i put your code it gives me a blank page. And if i put just "echo ..." i got this error "Fatal error: Using $this when not in object context in /home/user999/public_html/mydomain.com/wp-content/plugins/wordpress-seo/frontend‌​/class-frontend.php on line 809" – ukelele2 Oct 3 '12 at 23:35
ok, let's see how you're implementing this code. I tested it and it works fine in a post loop, where the post has a Yoast SEO meta description filled in. – Ben Oct 4 '12 at 0:04
I'm implementing on archives.php for categories. I'm using "Meta description template" in "Titles & Metas" option from Yoast SEO. – ukelele2 Oct 4 '12 at 9:23
Fatal error: $this when not in object context in /home/..... and yes, the error occurs with the code within the loop. – gurung Jan 10 '14 at 9:28


<?php $object = new WPSEO_Frontend();
        echo $object->metadesc( false ); ?> 
share|improve this answer
Some explanations could turn this fragment into an answer. ;) – toscho Oct 4 '12 at 22:18
+1 for this solution. This works like charm in and outside the loop. Thanks Ukelele. – gurung Jan 10 '14 at 9:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.