禁用 WordPress 首页上的最新帖子突出显示
目前,我的 WordPress 网站首页上显示的导航菜单(由帖子列表组成)中突出显示了最新的帖子。然而我不想要这个。有没有办法可以更改它,以便在首页上导航没有开启状态,但在所有其他帖子页面上却有开启状态?
下面是我认为它生成它的代码:
<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_title(); ?></a>
</li>
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_title(); ?></a>
</li>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除
元素标记内的 php。如果没有该网站的链接,我不能肯定地说,但我认为这就是它的作用。无论如何,
$post->ID == $wp_query->post->ID
几乎总是返回 true,因为$post
是$wp_query- >发布
。自定义循环可以改变这一点,但我很确定导航菜单不会覆盖全局 $post 变量。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.