[wp-testers] Can't use $wp_query the same way anymore

Karl Wångstedt wordpress at wangstedt.net
Fri Dec 23 09:31:40 GMT 2005


Hi everyone

I guess this is some sort of bug or change to 2.0, but I don't seem  
to find anything in the codex or support forum, so I'll try here.

I've just recently started to test my current site with the nightly  
builds of 2.0. So far I'm really happy, but one thing isn't really  
working for me. I have a lot of customizations done, since I'm using  
WP as a CMS more or less.

What I've done is to make a list (menu) of all posts within a  
specific category and have a function that checks if one of the posts  
are shown. If so, it inserts a "current_page_item"-class so I can  
style that <li> as active.

This seem to have broken for me in 2.0. Here are the code:

<ul>
<?php $my_query = new WP_Query('cat=1');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li class="page_item<?php if (is_single()) {
if ($post->ID == $wp_query->post->ID
{
echo (' current_page_item');
}
}
?>"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>

It seems like $post->ID and $wp_query->post->ID returns the same  
number, witch makes all <li> tags have the active class.

How can I correct this?
---------------------------------
W W W . W A N G S T E D T . N E T

Karl Wångstedt      0278-61 12 33
Stenhuggarvägen 3g  070-578 13 04
821 41  BOLLNÄS
---------------------------------
Det här brevet skickades med en Macintosh från Apple.
Garanterat virusfri med Mac OS X.



More information about the wp-testers mailing list