WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used single.php for this code:

<?php $categories = get_the_category($post->ID);
if ($categories) {
    $category_ids = array();
    foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
        'category__in' => $category_ids,
        'post__not_in' => array($post->ID),
        'showposts'=>6, //Gösterilecek yazı adeti
    $benzer = new wp_query($args);
    if( $benzer->have_posts() ) {
        while ($benzer->have_posts()) {
    <div class="urundetaykutu">
        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    <?php } } wp_reset_query(); }?>

This code working, but I want to use pagination in the loop.

share|improve this question

Try adding

'paged' => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1, // this will get the right posts for the current page (i.e. if the user loads www.domain.com/blog/page/2 directly)
'posts_per_page' => '6'

to your $args and delete showposts

showpostsis deprecated.

From the Codex reference for WP_Query:

showposts (int) - number of posts to show per page. Deprecated as of Version 2.1 in favor of 'posts_per_page'.

Add Pagination links:

<?php next_posts_link( '&larr; Older posts' ); ?>
<?php previous_posts_link( 'Newer posts &rarr;' ); ?>
share|improve this answer
ok, but pagination not work. Only, three posts show. I want to do paging in this code. – Mehmet Alp Oct 15 '12 at 13:57
You have to add pagination links. I've edited the answer. Working now? – xsonic Oct 15 '12 at 13:59
add pagination links but not work. added(pagination links) to the bottom of the code. here after; <?php } } wp_reset_query(); }?> '<?php next_posts_link( '&larr; Older posts' ); ?> <?php previous_posts_link( 'Newer posts &rarr;' ); ?>' – Mehmet Alp Oct 15 '12 at 14:31

Your Answer


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.