questine about WordPress
- Started
- Last post
- 6 Responses
- qoob
Hi QBN,
How can I write the code in WordPress so that it adds the name of the nav item as an ID?
For example,
<li id="home">Home<li>
- plash0
knowledge in html, php, css is helpful
the wp codex has some good info on menus:
http://codex.wordpress.org/Creat…
http://codex.wordpress.org/Funct…
http://codex.wordpress.org/Templ…
http://codex.wordpress.org/Funct…if you're talking in general, the home link.
<li><a href="<?php echo get_settings('home'); ?>">Home</a></li>
- qoob0
Think you misunderstood, I'm asking how to add the name of the page (page slug) into the HTML as it creates the nav.
Normally WordPress renders it as:
<li class="page_item page-item-3">About</li>
I'd like it to be:
<li id="about">About</li>
- plash0
you might just need to change to permalinks and use the post slug as the id. eg: %postname% http://codex.wordpress.org/Using…
- rizm0
To write the current pagename, that's very easy:
<?php $wp_query->queried_object->post_name ?>
See here: http://stackoverflow.com/questio…But I guess you're looking for menu highlighting? Then check here:
http://codex.wordpress.org/Dynam…But come on, anyone can use Google these days!
- qoob0
Seems like no one here actually reads the question before answering. ಠ_ಠ
For the third time...I'm trying to add page names as a class or ID to each nav list item within the WordPress nav function.
Not printing the pagename or highlighting the current page.
- Hue0
Under Appearance>menus create a custom menu for your navigation and for each item you can add an individual class