WordPress.org

Ready to get started?Download WordPress

Forums

Removing Posts from the_loop? (2 posts)

  1. chrisvallleyoc
    Member
    Posted 7 months 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) ) {
    		continue;
    	} else {
    		[Code to display posts]
    	}
  2. TheHandOfCod
    Member
    Posted 7 months 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.

Reply

You must log in to post.

About this Topic