Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

in a blow I'm working on there is a navigation menu made of pages and subpages. I didn't code it, so I'm not completely sure how it works, but after reading some code it seems that the menu is generated by this line in the navivation.php file.

<?php wp_list_pages('title_li=&depth='.$bpt_navigation_depth.'&sort_column=menu_order'); ?>

Now, I had to manually build another menu. I just created a list and inserted links to the pages I needed, without using any wordpress function. Some of these links are in the other menu too, so I want to remove them from there. I tried doing this:

<?php $args = array(
    'depth'        => 0,
    'show_date'    => '',
    'date_format'  => get_option('date_format'),
    'child_of'     => 0,
    'exclude'      => '17',
    'include'      => '',
    'title_li'     => __('Pages'),
    'echo'         => 1,
    'authors'      => '',
    'sort_column'  => 'menu_order, post_title',
    'link_before'  => '',
    'link_after'   => '',
    'walker'       => '',
    'post_type'    => 'page',
        'post_status'  => 'publish' 
); ?>


        <?php wp_list_pages($args); ?>

But what happens is that it creates a menu with one single element named 'Pages', which contains a submenu with all the other pages and, anyway, it doesn't exclude the page 17.

share|improve this question
add comment

2 Answers

try to edit your code to:

<?php wp_list_pages('title_li=&depth='.$bpt_navigation_depth.'&sort_column=menu_order&exclude=17'); ?> 
share|improve this answer
add comment

I'm not entirely clear on what you are trying to do exactly because "I had to manually build another menu. I just created a list and inserted links to the pages I needed, without using any WordPress function." didn't make a whole lot of sense.

You need to exclude pages by including the exclude parameter within your wp_list_pages function.

E.g. (example: 'exclude=3,7,31').

<?php wp_list_pages('title_li=&depth='.$bpt_navigation_depth.'&sort_column=menu_order&exclude=17'); ?>

That aside concerning the second snippet of code, you likely do not need to call each of those parameters, not unless you are using each of them.

So trim back those arguements to the bare minimum of what you need to accomplish.

<?php $args = array(
    'depth'        => 0,
    'exclude'      => '17',
    'sort_column'  => 'menu_order, post_title',
    'post_type'    => 'page',
    'post_status'  => 'publish' 
); ?>

<?php wp_list_pages($args); ?>

That's enough to get you going and you can add or remove arguments as you need them.

If you are trying to build a list of all pages except page where ID equals 17 then the above snippet will work for you.

Let us know!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.