Support » Fixing WordPress » Exclude links from certain pages using wp_list_pages()

  • Resolved David Gard


    Hey all,

    Does anybody know if there is any easy way of excluding a link from a page using wp_list_pages()?

    I have a page that has several children, so I want them displayed when users hover over the parent – trouble is, the parent will alway contain no data but allows people to link to it.


Viewing 4 replies - 1 through 4 (of 4 total)
  • You can exclude certain pages using the page ID, so like:

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

    I hope this helps. You can find more information here:

    Thanks Winifred, but I wasn’t looking to exclude certain pages, mearly to make it so that the link to them did not work. I haven’t found an *easy* way, but creating a custom Walker (below) and grabbing the pages like this works –

    /** Get the pages to display in the nav */
    $list_page_args = array(
    	'depth' => 2,
    	'echo' => 0,
    	'exclude' => $exclude,
    	'no_link' => array(8,9,10,170),
    	'title_li' => '',
    	'walker' => new Walker_Custom_Page
    $pages = wp_list_pages($list_page_args);

    Custom walker in functions.phpin this Paste Bin

    Oooh, apologies 🙂 Glad you found a solution anyhow.

    No worries – that’s the trouble with text, so hard to get context across. As soon as I pressed ‘Post’ I thought someone would interpret it that way!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude links from certain pages using wp_list_pages()’ is closed to new replies.