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

Doug Stewart zamoose at gmail.com
Fri Dec 23 14:13:11 GMT 2005


Dunno about the WP code, but I believe that underscores are invalid in
CSS selectors.  You might want to switch 'em to dashes...

-Doug

On 12/23/05, Karl Wångstedt <wordpress at wangstedt.net> wrote:
> 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.
>
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers
>


More information about the wp-testers mailing list