I've got a custom loop function in my child theme, in the templates.php file to loop through specific post types ('listings') and then put it into an array to use into a part of my template.
Here's an example of the code
public function loop()
{
global $wp_query;
$featured = $regular = array();
foreach ($wp_query->posts as $count => $post)
if (has_term('featured', 'listings_tag', $post->ID))
$featured[] = $post;
else
$regular[] = $post;
$posts = array_merge($regular, $featured);
$posts = array_reverse($posts);
include('templates/loop.php');
}
So this is great, however, it paginates after every 11 posts. Instead I would like it to display everything instead.
I tried by adding a custom action in my functions.php, making use of the 'pre_get_posts' hook. However it doesn't have any effect on my code.
function show_all($query){
if (is_post_type_archive('listings') && $query->is_main_query()) {
$query->set('nopaging', True);
}
}
add_action('pre_get_posts', 'show_all');
Any suggestions?
$query->is_post_type_archive.....
. Otherwise,nopaging
doesn't do what you think it does. Likewise it looks like you've re-implemented sticky posts