404 error when I acess the second page of post-type

How can I fix this, I get an error 404 when I access the second page of post-type:

web.site/clipuri/2012/

Read More

web.site/clipuri/2012/page/2/

register_post_type('clip', array(   'label' => 'Clip','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => true,
'rewrite' => array('slug' => ''),
'query_var' => true,'has_archive' => true,
'menu_position' => 5,'supports' => array('title','editor','custom-fields','category', 'post_tag',),
'labels' => array (
'name' => 'Clip',
  'singular_name' => 'Clip',
  'menu_name' => 'Clip',
  'add_new' => 'Add Clip',
  'add_new_item' => 'Add New Clip',
  'edit' => 'Edit',
  'edit_item' => 'Edit Clip',
  'new_item' => 'New Clip',
  'view' => 'View Clip',
  'view_item' => 'View Clip',
  'search_items' => 'Search Clipuri',
  'not_found' => 'No Clip Found',
  'not_found_in_trash' => 'No Clip Found in Trash',
  'parent' => 'Parent Clip',
),) );

register_taxonomy("clipuri","clip", array("hierarchical" => true, "label" => "Cat Clip", 'show_ui' => true, 'query_var' => true, "singular_label" => "clipuri", "rewrite" => true, 'with_front' => true));

In the theme I use:

<?php global $wp_query;
$args = array_merge( $wp_query->query, array( 'post_type' => 'clip')  );
query_posts( $args ); ?>

<div class="nav">
<?php if(function_exists('wp_paginate')) {wp_paginate();} ?>
</div>

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

Related posts

Leave a Reply

1 comment

  1. For modifying the main query, I think it is best to take advantage of the pre_get_posts action.

    When using pre_get_posts the $query variable is passed “by reference” which means we can directly manipulate the $query object with the shortcut functions such as set_query_var. Remove the query code from your taxonomy template, and try the following in your functions.php:

    function wpa_66609( $query ) {
        if ( is_tax('clipuri') && is_main_query() ) {
            set_query_var( 'post_type', array('post','clip' ) );
        }
    }
    add_action( 'pre_get_posts', 'wpa_66609' );
    

    If that doesn’t work, I’ll try to debug it.