开发者

in wordpress, how do I know what page is current?

in wordpress, how do I know what pag开发者_如何学Pythone is current?

I have 5 pages that are my header menu bar, I want to CSS the current (open page) so user knows whats page they are on. Is there a way of doing this?

thanks


You should be able to use the is_page() function. You can use the page id, name or slug as an argument.

Examples:

<a href="#" <?php if(is_page(42)) echo 'class="active"'?>>Page 42</a>
<a href="#" <?php if(is_page('About Us')) echo 'class="active"'?>>About Us</a>
<a href="#" <?php if(is_page('our-friends')) echo 'class="active"'?>>Our Friends</a>


using CSS, you can style the current page of WordPress.

CSS:

li.current_page_item a {
   color: red;
}

this WordPress Codex page may explain the whole process better: http://codex.wordpress.org/Dynamic_Menu_Highlighting

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜