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.

Edit :

Toscho said this was a duplicated question and gave me a link Pagination not working with custom loop

I checked it out and followed the steps but this is not working for me. Right now. when i click on 2. it sends me to my error 404 page.

So i made a page in wordpress called nieuws and created a file called page-nieuws.php.

The custom post type i made for looping in page-nieuws.php

function create_nieuws()
{
$labels = array(
    'name' => 'Nieuws',
    'singular_name' => 'Nieuws',
    'add_new' => 'Toevoegen',
    'add_new_item' => 'Toevoegen nieuwsbericht',
    'edit_item' => 'Wijzig Nieuwsbericht',
    'new_item' => 'Nieuw Nieuwsbericht',
    'view_item' => 'Weergeven Nieuwsbericht',
    'search_items' => 'Zoek Bericht',
    'not_found' => 'Geen nieuwsbericht gevonden',
    'not_found_in_trash' => 'Geen nieuwsbericht gevonden in prullenbak',
    'parent_item_colon' => '',
    'menu_name' => 'Nieuws'
);

// #Arguments.
$args = array (
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'query_var' => true,
    'rewrite' => array('slug' => 'nieuws'),
    'has_archive' => false,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'thumbnail', 'editor', 'revisions' )
);

And this is the loop inside page-nieuws.php

          global $wp_query;
          $temp = $wp_query; 
          $args = (array(
          'post_type' => 'nieuws',
          'posts_per_page' => 5,
          'paged = $paged',
          'order' => 'DESC'));
          $wp_query = new WP_Query();
          $wp_query->query($args); 
          while ($wp_query->have_posts()) : $wp_query->the_post(); 
          ?>
          <div id="nieuws_item">
            <div id="nieuws_item_container">
                <span class="title_text marginTop25"><?php the_title(); ?></span>
                <span class="pos_indegaten font12"><?php echo get_post_meta( $post->ID, '_secondtitle' , true ) ?><br /></span>
                <?php the_post_thumbnail(array(180,200)); ?>
                <div id="nieuws_item_content" class="font12">
                <?php the_excerpt(); ?>
                <a class="font12" href="<?php the_permalink();?>"><?php _e('Lees meer...') ?></a>
                </div>
            </div>
         </div>  
<div id="nav">
get_pagination();
</div>

And this is the function pagination

function get_pagination()
{
    global $wp_query;

    $total_pages = $wp_query->max_num_pages;

    if($total_pages > 1)
    {
        $current_page = max(1, get_query_var('page'));
        echo '<span class="pagenavi_text">';
        echo _e('Page ');
        echo $current_page;
        echo _e(' Of ');
        echo $total_pages;
        echo '</span> ';
        echo paginate_links(array(
             'base' => get_pagenum_link(1) . '%_%',
             'format' => 'page/%#%',
             'current' => $current_page,
             'total' => $total_pages,
             'prev_text' => __('Prev'),
             'next_text' => __('Next')
             ));
    }
}

So what am i doing wrong that pagination is not working ?.

The permalink to the posts in the custom post type works. reading out works but only doing the pagination isnt.

share|improve this question
1  
where do you set $paged? –  Milo Apr 24 '13 at 7:37
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.