Hey folks,
I’m using a loop similar to the code shown in this page for a Custom Post Type archive page: http://css-tricks.com/snippets/wordpress/paginate-custom-post-types/
But I am adding one additional filter, referring to an ACF field with a specific value.
Now the loop seems to work fine with regards to the posts that are displayed, but the pagination seems to still count all the posts and doesn’t cater for the ones that have been filtered out via the ACF field.
Any suggestions?
This question sounds like it’s related directly to this other question http://support.advancedcustomfields.com/forums/topic/wp-loop-via-checkbox-value/
The pagination function will work without doing a new query for your custom post type. I wouldn’t follow that post.
The correct way to do this is to create a template for your custom post type archive following the WP template hierarchy and then do a pre_get_posts action like I showed in that question.
Previous and next post link function are documented here https://codex.wordpress.org/Function_Reference/previous_posts_link and here https://codex.wordpress.org/Template_Tags/next_posts_link