Support » Fixing WordPress » Exclude page from query_posts()

  • This seems simple, but I cannot find an answer anywhere. I have the query:

    <?php query_posts(‘post_type=page&orderby=title&order=asc&posts_per_page=-1′,’showposts=8’); ?>

    which, then leads into “the loop” to display some specific information about my pages.

    However, there are a couple pages I don’t want to show up. I would prefer to remove these from the query, so they don’t show. Then, as I add pages they will dynamically appear. But, the only thing I can get to work is the opposite… limit the query to cally specific pages:

    <?php query_posts(‘post_type=page&page_id=241&orderby=title&order=asc&posts_per_page=-1′,’showposts=8’); ?>)

    Any suggestions?

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi


    Forum Moderator

    Every time I try to implement that method the page breaks… perhaps I am not using it correctly. What would be the proper way to implement the ‘post__not_in’ parameter in the code I posted above?

    I got it working after a little more effort. For posterity’s sake here’s the code I used:

    <?php query_posts(array(‘post__not_in’=>array(2,69,78,80,237),’post_type’=>page,
    ‘orderby’=>title,’order’=>ASC,’posts_per_page’=>-1,’showposts’=>8)); ?>

    where 2,69,78,80,237 were the pages I wanted to exclude

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude page from query_posts()’ is closed to new replies.