WordPress儿童导航a:当前样式 [英] WordPress child nav a:current styling
问题描述
我目前正在为一个客户端工作的网站 - 这一切都工作正常,但在导航我已设置的子链接使用以下代码
I'm currently working on a site for a client - It is all working fine but within the navigation I have setup of for the child links using the following code
<div id="sub_nav_del">
<h4>Take a seat</h4>
<?php
$subnav_parent = ($post->post_parent) ? $post->post_parent : $post->ID;
$pages = get_pages('child_of=' . $subnav_parent . '&sort_column=menu_order');
$count = 0;
foreach($pages as $page)
{ ?>
<ul>
<li>
<h5 class="del">
<a href="<?php echo get_page_link($page->ID) ?>" ><?php echo $page->post_title ?></a>
</h5>
</li>
</ul>
<?php
}
?>
</div>
您可以在 http://www.lagourmetteria.co.uk/take-a-seat/wine-room/ ,对于那个页面我希望当前页面链接橙色。
You can see an example at http://www.lagourmetteria.co.uk/take-a-seat/wine-room/, for that page I would like the current pages link orange.
我想让它当前的链接是一个不同的颜色只是在子导航。有一个简单的方法来做到这一点,不幸的是我的PHP技能不是太棒了。
I would like it to make the current link to be a different colour just within the child navigation. Is there a simple way to do this, unfortunately my PHP skills aren't fantastic.
推荐答案
< body>
中的一个类,它是葡萄酒室
(可能是slug)。所以在你的CSS你可以做以下的魔法:
You already have what you need as a class in the <body>
which is wine-room
(probably the slug). So in your CSS you can do the following magic:
body.wine-room a[href*="wine-room"],
body.tasting-room a[href*="tasting-room"],
body.food-drink-menu a[href*="food-drink-menu"],
body.have-it-all-private-parties a[href*="have-it-all-private-parties"]
{
color: orange !important;
}
UPDATE
添加了该子菜单上的所有lug。。
Added all slugs on that submenu.
UPDATE 2
新增!important
取代任何其他样式。
Added !important
to supersede any other style.
这篇关于WordPress儿童导航a:当前样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!