I have a little problem with my wordpress theme. So I just created a category-theme and I use following structure for my permalinks: /%year%/%monthnum%/%postname%/.
Pagination worked at first not, but now I’ve managed to make it run, finally. The links
<div class="pagination">
<div class="alignleft"><?php previous_posts_link('« neuere Artikel') ?></div>
<div class="alignright"><?php next_posts_link('ältere Artikel »','') ?></div>
</div>
are showing.
The main problem is when I click on the “next_posts”-Link or on the previous_posts-Link I’ll get a 404.
Here is my code:
<?
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query->query(array(
'posts_per_page' => 5,
'orderby'=> 'menu_order',
'paged'=>$paged
) );
?>
<?php if (have_posts()) : ?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="type-post">
<h2><a href="<?php echo get_permalink(); ?>"><?php echo get_the_title(); ?></a></h2>
<div class="blog-date">
<a class="admin" href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>"><?php the_author_meta('display_name'); ?></a>
<a href="#" class="date"><?php the_time('j. F, Y'); ?></a>
<a href="<?php comments_link(); ?>" class="comments"><?php comments_number('0 Kommentare','1 Kommentar','% Kommentare'); ?></a>
</div><!-- close .blog-date -->
<p><? echo wp_trim_words( get_the_content(), 100 ); ?> </p>
<p class="alignright"><a href="blog-single.php" class="button">Read more</a></p>
<div class="clearfix"></div>
</div>
<?php endwhile; ?>
<!-- END Single Content -->
<div class="pagination">
<div class="alignleft"><?php previous_posts_link('« neuere Artikel') ?></div>
<div class="alignright"><?php next_posts_link('ältere Artikel »','') ?></div>
</div>
<?php endif; ?>
<div class="clearfix"></div>
<!-- END CONTENT -->
<?php $wp_query = null;
$wp_query = $temp; ?>
But it still does not work. Does anyone can help me with this? Thanks in advance. <3
Go to
and set
Blog pages show at most
andSyndication feeds show the most recent
same asposts_per_page
option inwp_query->query
.In your code
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
get_query_var(‘paged’) replace with get_query_var(‘page’)