Exclude certain post formats from pagination
I have the standard blog post format and gallery format. I have excluded all the gallery posts from the index.php page so only standard posts show up there. However, the gallery format posts are still being counted for pagination and there is just a blank space on the pagination pages where there would be a gallery post format. How can those be excluded from pagination?
?php echo paginate_links(); ?
I tried this but it didn't help:
?php
$args = array(
'post_type' = 'post',
'tax_query' = array(
array(
'taxonomy' = 'post_format',
'field' = 'slug',
'terms' = array(
'post-format-gallery'
) ,
'operator' = 'NOT IN',
) ,
)
);
?
?php echo paginate_links($args); ?
This is the query that displays the standard blog posts:
?php if (have_posts() ): ?
?php while (have_posts() ): the_post(); ?
?php $format = get_post_format( $post_id ); ?
?php if($format != 'gallery'): ?
div class="blog" style="width: 350px"a href="?php esc_url(the_permalink()); ?" class="w-inline-block"?php the_post_thumbnail(); ?/a
div class="gallery-info"a href="?php esc_url(the_permalink()); ?" class="linkgallery"?php the_title(); ?/a/div
?php $the_category = get_the_category(); ?
div class="gallery-info gallery-category"?php foreach($the_category as $category): ??php echo $category-cat_name . ' '; ?
?php endforeach; ?
/div
/div
?php endif; ?
?php endwhile; ?
?php wp_reset_postdata(); ?
?php endif; ?
Topic post-formats pagination Wordpress
Category Web