How can I fix this, I get an error 404 when I access the second page of post-type:
web.site/clipuri/2012/
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(); ?>
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 asset_query_var
. Remove the query code from your taxonomy template, and try the following in your functions.php:If that doesn’t work, I’ll try to debug it.