wp_list_pages different id's for css styling?
-
Hi, I’m using wp_list_pages() and have a specific icon for each li. In css I have to use page-item-xx to style it. It would be much better to have id’s or classes like ‘about’ and ‘contact’ rather than ‘page-item-14’ and ‘page-item-12’.
Here is the code I have.
<ul> <li id="home"><a href="#">home</a></li> <?php wp_list_pages('&title_li=&include=14,12');?> </ul>
I tried the plugin classy-wp-list-pages which would be the solution except that it doesn’t work. It appears to be broken. I’ve tried the newest version and the previous version but it only adds a class to the first page link.
Is there not a way to put this dynamically in the parameters of wp_list_pages() method?
I tried this:
<ul> <li id="home"><a href="#">home</a></li> <?php wp_list_pages('link_before=<span id='.get_the_title().'>&link_after=</span>&title_li=&include=14,12');?> </ul>
and it looks like I’m getting somewhere but the output is applied to a span inside the anchor this way and it strangely outputs
<span id="My" post="" third="">About</span>
So does anyone know of a way to put the class or id into the li based on the title of the page so it would have an id of ‘about’ or ‘contact’? Or another way to apply a different icon for each li?
Thanks
- The topic ‘wp_list_pages different id's for css styling?’ is closed to new replies.