WordPress.org

Ready to get started?Download WordPress

Forums

<?php wp_list_pages(); ?> create to mutch code!!! (8 posts)

  1. wpwork
    Member
    Posted 9 years ago #

    The code <?php wp_list_pages(....); ?> in the navlist.php file create huge code:

    <li id="pagenav">
    Pages
    <ul>
    <li class="page_item"><a href="link">Page 1</a></li>
    <li class="page_item"><a href="link">Page 2</a></li>
    </ul>
    </li>

    I dont need the tags
    <li>,
    <ul>,
    <li>
    ....
    I will create a navigation with static and direkli links, iclude the "wp_list_pages" - all in one!! list (
    <ul>
    <li>)<br />

    regards

    wpw

  2. Mark (podz)
    Support Maven
    Posted 9 years ago #

    Remove that code, and instead hardcode the links instead.

  3. NuclearMoose
    Member
    Posted 9 years ago #

    WordPress strives to be a semantic product, and a list of links is a list, ergo it is built using <ul> and <li> elements. It's up to you whether or not you want to use them.

  4. wpwork
    Member
    Posted 9 years ago #

    In which file I have to delete the list HTML elements?
    (ul and li elements are good, but for a normal navigation the php query wp_list_pages() create to mutch list elements.)

    HTML Generation by PHP is not good.
    Can we fix that problem in a next release?

    THX

  5. Mark (podz)
    Support Maven
    Posted 9 years ago #

    I like the xhtml generation - if I am writing a list (and no matter which way you spin it, a list of pages is a LIST) - then I'd rather WP handle that markup. To ask for it to be fixed implies it is broken - it is not.

    I have given you the answer - hardcode the links.

  6. angsuman
    Member
    Posted 9 years ago #

    I think the problem is that quite some functions in WordPress generates a list with html tags without providing the option to substitute other elements instead of ul and li.

    WordPress strives to be a semantic product, so it is more important not to tie with a particular syntax. Providing a default is fine, however making it the only option...

    While re-designing my blog I found several such functions, which even though useful was clearly unsuitable for my purposes. So I was forced to redesign most of the template tags for my needs.

    For example I use two "The Loop". However I realized it is wasteful to run the full loop when I can provide an optimized query to just fetch what I need.

    Same with category template tags, too much ul, li based and some of them makes assumptions about being within "The Loop".

  7. wpwork
    Member
    Posted 9 years ago #

    A small solution :

      <?php wp_list_pages('title_li='); ?>

    found on: http://codex.wordpress.org/Template_Tags/wp_list_pages#Display_No_Heading_and_Not_in_a_List

  8. idbehold
    Member
    Posted 9 years ago #

    I think the next version of WordPress should have an interface to allow the easy modification of all the WP operators, such as wp_list_pages. Allow people to change the before after and inbetween stuff.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.