开发者

Disable latest post highlighting on WordPress front page

Currently the navigation menu (consisting of a list of posts) that appears on the front page of my WordPress site has the most recent post highlighted in it. However I don't want this. Is there a way I can change it so that on the front page the navigation doesn't have an on-state, but on all other post pages it does?

Below is the code that I think it generating it:

<li<?php echo((!is_front_page() AND $post->ID == $wp_query->post->ID) ? ' class="selected"' : ''); ?>>

    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the开发者_C百科_title(); ?></a>

</li>


Get rid of the php inside the <li> element tag. Without a link to the website, I can't say for sure, but I think that's what's doing it. Anyway, $post->ID == $wp_query->post->ID will almost always return true, since $post is $wp_query->post. Custom loops can change this, but I'm pretty sure nav menus don't override the global $post variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜