简体   繁体   中英

wordpress pagination with custom permalinks

I use this "custom" pagination script for my wordpress template:

$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('showposts='.get_option( 'posts_per_page' ).'&paged='.$paged);

while ($wp_query->have_posts()) : $wp_query->the_post();
    echo '<a class="current";
    echo '" href="';
    the_permalink();
    echo '">';
    the_title();
    echo '</a>';
endwhile;
next_posts_link('Load more articles...'); 
$wp_query = null; $wp_query = $temp;

So in the end, it creates a "load more" button that goes to http://blog.com /page/2 Now the problem is that with custom permalinks the url resembles this: http://blog.com /custom/stuff /page/2 which breaks the script and does not display the next result but the originals.

Might nay of you know how I can fix this? or maybe force http://blog.com /page/2 in functions.php?

Thanks for your help guys!

I was having the same problem for ages and then tried setting this in my custom permalink settings which worked for me: /%postname%/.

The dot after the last / is essential to get it working. Maybe not that pretty but hey it works for me :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM