• I am trying to control the list of pages dispayed in my main menu. I have tried to use the ‘exclude’ and ‘include’ statements in wp_list_pages but they don’t seem to work. The generic code is:

    • “>Home
    • ‘<?php wp_list_pages(‘title_li=&depth=0&sort_column=menu_order’); ?>

      I have tried changing it to this, but nothing happens on the page:

    • “>Home
    • ‘<?php wp_list_pages(‘exclude=10&title_li=&depth=0&sort_column=menu_order’); ?>

      I have also tried this, but then only the link to ‘Home’ appears:

    • “>Home
    • ‘<?php wp_list_pages(‘include=2&title_li=&depth=0&sort_column=menu_order’); ?>

      Can anyone tell me what I’m doing wrong?
      Thanks,
      Joe

Viewing 4 replies - 1 through 4 (of 4 total)
  • what is the site url?

    Thread Starter jduehmig

    (@jduehmig)

    Looks like the code I posted is a bit messed up. Can anyone make sense of it?
    Thanks,
    Joe

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Look down at the bottom of the screen, below the editing box. See where it says “Put code in between backticks.”? That means you too.

    The backtick is right below the tilde ~ on your keyboard.

    I’m also trying to exclude pages from being listed in my menu bar. I found a tutorial that says to type this…

    <?php wp_list_pages('exclude=17,38' ); ?>

    …(the number being page IDs), but my code looks like this:

    <?php
    $pages = wp_list_pages('sort_column=menu_order&title_li=&echo=0');
    $pages = preg_replace('%<a ([^>]+)>%U','<a $1><span>', $pages);
    $pages = str_replace('</a>','</span></a>', $pages);
    echo $pages;
    ?>

    Where should I enter the “exclude” text?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_list_pages won’t exclude pages’ is closed to new replies.