php - Hide specific posts from category list in wordpress -


i'm having trouble displaying list of posts wordpress category exclude number of post based on custom field using advance custom fields.

here's current code i'm using hides nicely:

while ( have_posts() ) : the_post();     $is_taken = get_field('taken_check', $this_id);     if ($is_taken!=1) {          get_template_part( 'basket_selection' );     }  endwhile; 

however, hides post still considers post on "posts_per_page" function.

for example, there 20 posts in total , i've set limit 10 posts per page. if hide 3 posts code above, display 7 posts in page 1 , 10 posts in page 2.

is there way ignore hidden posts , not count "post"?

try this: apply custom fields parameters in get_post query itself.

$posts = get_posts(array(     'posts_per_page' => 10,     'post_type' => '<your_post_typ>',     'meta_key' => 'taken_check',     'meta_value' => '<default_value_of_taken_check>' )); 

lots read here: http://codex.wordpress.org/template_tags/get_posts


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -