Detect pages with class name
-
Hy All,
I am newbie in WordPress. I have problem how to show page.
I want show page with class name. So, the structure page in html like this.<ul id="topnav"> <li class="about"><a href="#">About Us</a> <ul> <li><a href= "#">Company Profile</a></li> <li><a href= "#">Vission and Mission</a></li> <li><a href= "#">Who Works For Us</a></li> <li class="clear"><a href= "#"> </a></li> </ul> </li> <li class="produk"><a href="#">Produk</a></li> <li class="promosi"><a href="#">Promosi</a></li> <li class="partnership"><a href="#">Partnership</a></li> <li class="support"><a href="#">Support</a></li> </ul>Please help me, thank you.
-
I think jQuery can do it:
<script type=”text/javascript”>
jQuery(document).ready(function(){
jQuery(‘ul#topnav > li’).each(function(index){if(index == 0){
jQuery(this).addClass(‘about’);
}if (index == 1){
jQuery(this).addClass(‘produk’);
}…….
});
});
</script>Thanks 🙂
But, i mean i have navigation menu like this :
+—————————————-+
| About | Produk | Promosi | Partnership |
+—————————————-+And each menu have different class name, generated with wp_pages().But i don’t know how to add attibrute ‘class’ in wp_pages() tag.
I hope, with different class can make differentiate each menu.Because i want to add submenu on it.
Creating and managing menu can be done at WP-Admin under Appearance->Menus. Then, you can add classes to each item in the menu by going to the screen options on top right and tick css classes.
After that, you will notice a css class box in menu item dropdown (in the same place where you edit each item name).
You can also make a drop down by dragging and drop another item below the parent item.
The topic ‘Detect pages with class name’ is closed to new replies.