WordPress.org

Ready to get started?Download WordPress

Forums

Exclude page from query_posts() (4 posts)

  1. ts500
    Member
    Posted 5 years ago #

    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?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 5 years ago #

  3. ts500
    Member
    Posted 5 years ago #

    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?

  4. ts500
    Member
    Posted 5 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic