[wp-hackers] Echoing out Categories in a Post in/out of "the loop"
Owen Winkler
ringmaster at midnightcircus.com
Thu Aug 5 05:09:14 UTC 2004
> Here is my question: can the categories a post
> is filed under be echoed out of "the loop"?
Outside of the loop in 1.3 you may need to set $post to the current post
before you can call get_the_category (ergo the_catgory). WP 1.2 sets $post
inadvertently in wp-blog-header.php when it does something like this example
near line 460-470:
$posts = array('a','b','c');
foreach($posts as $post)
{
$z = $post; // Do something
}
echo $post; // Echoes 'c'
All of the logic above that was in wp-blog-header.php is now in a function
(functions.php:1767, update_post_caches()), which causes the $post that
leaks from the foreach to have a different scope, and is no longer visible
in index.php. Cleaner, but more troublesome for you, I suspect.
Owen
More information about the hackers
mailing list