Have a strange problem with pagination, the query work fine when I'm in homepage, but if click for the next page I get a 404
error. Disabling permalinks settings, I saw that in the query string (when I move on to the next page), then I have ?paged=2
as query argument, but not post_type=job_listing
(in this case). Here is my code:
global $wp_query, $paged;
if ( get_query_var( 'paged' ) )
$paged = get_query_var( 'paged' );
else
$paged = 1;
if ( get_query_var( 'post_type' ) )
$post_type = get_query_var( 'post_type' );
else
$post_type = 'job_listing';
$args = array(
'post_type' => $post_type,
'paged' => $paged,
);
query_posts( $args );
And then I have a normal loop cycle and a wp_reset_query()
at the end.
The problem is that when open a pagination link the url look like www.example.com/?paged=2
and not www.example.com/?post_type=job_listing&paged=2
which works if I type it manually.
I tried everything to make it work but it keeps ignoring the post_type
var in all pages.
query_posts()
? What template file is this?paginate_links()
, maybe you can pass your query var ->paginate_links('add_args' => array('post_type' => 'job_listing'));