wp_list_pages won't exclude pages (5 posts)

  1. jduehmig
    Posted 7 years ago #

    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:


  2. ">Home
  3. '<?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:


  4. ">Home
  5. '<?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:


  6. ">Home
  7. '<?php wp_list_pages('include=2&title_li=&depth=0&sort_column=menu_order'); ?>

    Can anyone tell me what I'm doing wrong?

  • viceng
    Posted 7 years ago #

    what is the site url?

  • jduehmig
    Posted 7 years ago #

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

  • 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.

  • mewing22
    Posted 7 years ago #

    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:

    $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?

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic