WordPress.org

Support

Support » Plugins and Hacks » Hacks » Removing Posts from the_loop?

Removing Posts from the_loop?

  • chrisvallleyoc
    Member

    @chrisvallleyoc

    I have a unique circumstance where I’m trying to hide specific custom posts from one of the loops in my template. It was fairly easy to hide them with an if statement in the loop to prevent them from being shown, but the pagination still counts them, so I have erroneous blank pages.

    Currently I’m using:

    if (have_posts()) : while (have_posts()) : the_post();
    	if (($post->post_parent) ) {
    		continue;
    	} else {
    		[Code to display posts]
    	}
Viewing 1 replies (of 1 total)
  • TheHandOfCod
    Participant

    @chrisodell

    I think if you only return the posts you want rather than using an if statement to filter out the posts that you do not want, then the paging will work. You can do this by using WP_Query and implmenting your own loop in the template. Have a look at WP_Query for more details.

Viewing 1 replies (of 1 total)
  • The topic ‘Removing Posts from the_loop?’ is closed to new replies.