Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using following functions to display pagination on archive pages of my site.

<?php previous_posts_link('< Previous', $loop->max_num_pages); ?>
<?php next_posts_link('More >', $loop->max_num_pages); ?>

And it is working very fine on my localhost. But not on my server, the issue is that we have some redirects written on my server's .htaccess and since my wordpress is subdomain I dont really want to touch my root .htaccess file.

Default pagination links my pages to

domain.com/wordpress/posttype/page/2
domain.com/wordpress/posttype/page/3

and so on.. but the above links gets redirected to something like following

domain.com/wordpress/posttype/page/blah2
domain.com/wordpress/posttype/page/blah3

which eventually returns 404 page. (ofcourse its due to .htaccess redirects on my server)

So All I want to do is change permalink structure for my pagination so that my pagination links look something like these :

domain.com/wordpress/posttype?page=2
domain.com/wordpress/posttype?page=3

Thank You.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You could filter get_pagenum_link. The parameter has to be paged, not page then.

add_filter( 'get_pagenum_link', 'wpse_78546_pagenum_link' );

function wpse_78546_pagenum_link( $link )
{
    return preg_replace( '~/page/(\d+)/?~', '?paged=\1', $link );
}

But I would rather try to fix the broken rewrite rules.

share|improve this answer
    
Thanks for your reply Toscho I'll give it a try. Just curious to know why cant i use page as parameter is that keyword reserved by wordpress? –  Kuldeep Daftary Jan 7 '13 at 12:14
    
@KuldeepDaftary page is for paged posts (one post split into multiple pages), paged is for paged archives, lists of posts. –  toscho Jan 7 '13 at 12:16
    
Oh I See! it makes total sense Thanks :) –  Kuldeep Daftary Jan 7 '13 at 12:18
    
Well it works! Thanks. Though as you suggested I asked server guy to change the redirect settings and ignore redirects for my wordpress directory. Thanks once again :) –  Kuldeep Daftary Jan 7 '13 at 12:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.