I have to get some custom post types and need to do that with WP_Query (query_posts doesn't work).
How can I do the pagination? Whatever I tried didn't work... any help would be awesome I can't crack this alone...
$args = array(
'tax_query' => array(
'posts_per_page' => 5,
array(
'author' => $user_id,
'taxonomy' => 'custom_taxtype',
'field' => 'slug',
'terms' => 'delicious-food',
)
)
);
$answer_query = new WP_Query( $args );
//// Loop trough the results
while ( $answer_query->have_posts() ) : $answer_query->the_post();
//// do something
endwhile;
paged => 1,2...n
argument, and I think thatposts_per_page
, as well aspaged
should be outside of thetax_query
array.paged
and set it to the page number you are looking for?