• Hi,

    I have to style my list of pages output in a certain way.

    Currently I’m using the default: <?php wp_list_pages(‘title_li=<h2>Pages</h2>’ ); ?>

    However, the output is not great. I get this:

    <ul id="navlist">
                		<li class="pagenav"><h2>Pages</h2>
    <ul><li class="page_item page-item-2"><a href="/?page_id=2" title="About">About</a>
    </ul>
    <ul>
    	<li class="page_item page-item-3"><a href="/?page_id=3" title="Our Team">Our Team</a>
    </ul>
    <li class="page_item page-item-6"><a href="/?page_id=6" title="Contact">Contact</a>

    When actually, I’d love to get :

    <ul id="navlist">
    
                    <li id="home"><a href="/">Home</a></li>
    
              			<li><a class="fly" href="/?page_id=2">About Us<!--[if gte IE 7]><!--></a><!--<![endif]-->
              			<!--[if lte IE 6]><table><tr><td><![endif]-->
              				<ul>
              					<li><a href="/?page_id=3">Our Team</a></li>
                      </ul>
                    <!--[if lte IE 6]></td></tr></table></a><![endif]-->
    			          </li>
    
                    <li id="contact"><a href="/?page_id=6">Contact</a></li>
                    </ul>

    It’s a little complex, but it’s just to get a bit of fancy CSS menu working ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi

    I don’t know of any way you are going to automatically generate code like that from a WP function. str_replace is used sometimes to insert standardized text into the output of wp_list_pages, but what you have is so customized there is nothing that could be standardized.

    There is a plugin called Page Lists Plus that lets you insert some code into the wp_list_pages output – a custom class per page item, and span tags around the inner content. It won’t take you all the way to where you want to go, but closer than what wp_list_pages can do.

    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    Many thanks for the reply.

    I will look into PageListsPlus.

    I’m considering trying a SQL query of my own, with a few if statements. This may be madness though ??

    Anyone else care to help too?

    Many thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Styling my ‘wp_list_pages’ output ?’ is closed to new replies.