In wordpress, how do I know which page is current?

in wordpress, how to find out which page is current?
I have 5 pages which are my title bar, I want the CSS to be the current (open page) so the user knows which page they are on. Is there a way to do this?

thanks

+2


a source to share


2 answers


You can use is_page () function. You can use page id, name or slug as 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>

      

+2


a source


using CSS you can create current WordPress page.

CSS



li.current_page_item a {
   color: red;
}

      

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

0


a source







All Articles