Quick php problem (excerpt in meta tag doesn’t work)
-
I want the opening lines of each post to be meta description of the post page (only post page so the script below isn’t what I’m looking for yet). Here’s my code that I placed in header.php:
<meta name="description" content="<?php if ( is_home() ) { print("MY DESCRIPTION FOR HOMEPAGE");} else { echo the_excerpt(); } ?>" />The problem is that the_excerpt(); (also get_the_excerpt(), the_content()) shows nothing.
the_title(); shows the title and other things like the_permalink(); work fine in this place.the_excerpt(); works fine on my homepage in loop showing all the posts but it doesn’t work in header.php in meta tag.
The topic ‘Quick php problem (excerpt in meta tag doesn’t work)’ is closed to new replies.