Ask your WordPress questions! Pay money and get answers fast! (more info)

pagination don't work on single-customposttype.php WordPress

i use this query_posts

$args = array(
'post_type'=> 'annonces',
'order' => 'DESC',
'posts_per_page' => 6,
'category_name' => 'ile-de-re',
'paged' => get_query_var('paged')
);

query_posts( $args );


in my template

if i use this template as page.php, no problem.
if i use this template as single-agences.php (for my custom-post-type "agences") i have a problem : pagination is managed with pagenavi and when i click on "2" (to see the page 2") the page is refreshed but don't change and the url don't change.

Do you know where is the problem ?

<strong>EDIT 1 :</strong>

if i use the default structure of permalinks, the problem disappears.

<strong>EDIT 2 :</strong>

if i use the default structure of permalinks, when i click on "2" (to see the page 2")
-the page is refreshed
-the url is ok
but the page is not the page i want to display and the pagination disappears

Answers (1)

2012-12-05

John Cotton answers:

Try:


if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
}
elseif ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}


and then used $paged for the 'paged' value in the array


Sébastien | French WordpressDesigner comments:

that doesn't work

I edit my question, to say that there is no problem if i use the default structure of permalink


John Cotton comments:

<blockquote>there is no problem if i use the default structure of permalink</blockquote>

What's the URL when it doesn't work?


Sébastien | French WordpressDesigner comments:

in fact there was no problem. I put it my query_post in a condition
if($paged>2)
I did not pay attention ^^

thx