get_the_excerpt – Outside the Loop
-
I’m trying to figure out why get_the_excerpt is delivering nothing except a line break in WP2.6. I’m echoing tags and the excerpt for meta keywords and description in my header file. I do this by setting $post as global in the header, if it’s a single post, then echoing tags through a foreach, then the excerpt via get_the_excerpt.
This works without problem in another blog I have, which is WP2.5.1. On the WP2.6 blog I’m having trouble with, echoing the tags works fine but get_the_excerpt results in only a line break. Edit: In both cases, I am not specifying an excerpt, but relying on the default 55-word filter inherent to WP.
Was get_the_excerpt changed between 2.5.1 and 2.6? Am I missing something brilliantly simple?
Here’s my code, outside the loop, in header.php:
To echo the excerpt:
<?php global $post; if (is_single()) { echo strip_tags(get_the_excerpt($post->ID)); } ?>
To echo the tags ($post is already global):
<?php if (is_single()) { foreach(get_the_tags($post->ID) as $tag) { echo $tag->name . ', '; } } ?>
I hope this makes sense, and I appreciate any help! Thanks!
- The topic ‘get_the_excerpt – Outside the Loop’ is closed to new replies.