Removing Posts from the_loop? (2 posts)

  1. chrisvallleyoc
    Posted 2 years ago #

    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) ) {
    	} else {
    		[Code to display posts]
  2. TheHandOfCod
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic