• Resolved avoidriskyfood

    (@avoidriskyfood)


    Hi All,
    so I have two problems both having to deal with un-needed li tags. Seems word press really likes it’s lists and they are driving me crazy.

    the first and most important is with my navigation:

    $list = wp_list_pages( array('echo' => 0, 'title_li' => __(' ')) );
    $list = preg_replace('/title=\"(.*?)\"/','',$list);
    echo $list;

    I’m using wp_list_pages and removing the title tags then out putting the menu. but it wraps the menu in an li tag. I need to know how to get rid of this I want:

    <ul>
       <li>Nav 1</li>
       <li>Etc...</li>
    </ul>

    but I’m getting:

    <li class="pagenav">
       <ul>
          <li>Nav 1</li>
          <li>Etc...</li>
       </ul>
    </li>

    I’m also having problems with my sidebar. Most of my sidebar elements are custom widgets so they are not a big deal but I have one that is a text widget and it is doing the same thing. wrapping itself in an li tag. is there anything I can do – apart from editing the source files?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The line which works for me is:

    echo preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<li$1><a$2><span>$3</span></a>', wp_list_pages('echo=0&orderby=name&exclude=181&title_li=&depth=1'));

    Then I surround it with ul tags

    dunno if this is it, but if title_li is totally blank it kills the pagenav li element

    like title_li=

    not sure about in your format tho….

    'title_li' => ) ); possibly?

    as for the sidebar….. the li is however your theme is set up. Either in sidebar.php or widget before and widget after in functions.php

    Thread Starter avoidriskyfood

    (@avoidriskyfood)

    Thanks! went with a combination of both:
    $list = wp_list_pages( 'echo=0&title_li=' );

    The above will output the pages in li’s so I needed to add a ul in my template:

    $list = wp_list_pages( 'echo=0&title_li=' );
    $list = preg_replace('/title=\"(.*?)\"/','',$list);
    echo '<ul id="nav">' . $list . '</ul>';

    for the sidebar, I think I’m just going to make another custom widget for that.

    Thanks again.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Removing crap li tags’ is closed to new replies.