404 error PageNavi custom type taxonomy | wordpress
I have a custom post type called rock
with a custom taxonomy called genero
. taxonomy-genero-curiosity.php
mypage/Rock/curiosity/
When i click subsequent paginated page links (e.g. [2], [3], [next])
mypage/Rock/curiosity/page/2
takes me to an 404 page.
?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
//for a given post type, return all
$args = array(
'tax_query' = array(
array(
'taxonomy' = 'genero',
'field' = 'slug',
'terms' = 'curiosity'
)
),
'post_type'='', //add your post type name
'posts_per_page' = 1,
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query-have_posts() ) {
while ($my_query-have_posts()) : $my_query-the_post(); ?
pa href="?php the_permalink() ?" rel="bookmark" title="Permanent Link to ?php the_title_attribute(); ?"?php the_title(); ?/a/p
?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?
?php wp_pagenavi( array( 'query' = $my_query ) ); ?
?php wp_reset_postdata(); ?
How can I fix this? What am I doing wrong?
EDIT
Here is how I register my post type
function my_custom_post_product() {
$labels = array(
'name' = _x( 'Rock', 'post type general name' ),
'singular_name' = _x( 'Rock', 'post type singular name' ),
'add_new' = _x( 'Add New', 'entry in rock' ),
'add_new_item' = __( 'Add New entry in rock' ),
'edit_item' = __( 'Modificar entry in rock' ),
'new_item' = __( 'New entry in rock' ),
'all_items' = __( 'all entry in rock' ),
'view_item' = __( 'see entry in rock' ),
'search_items' = __( 'search entry in rock' ),
'not_found' = __( 'Nothing entry in rock' ),
'not_found_in_trash' = __( 'Nothing entry in rock on thrash' ),
'parent_item_colon' = '',
'menu_icon' = get_bloginfo('template_directory'). '/images/my_menu_icon.png',
'menu_name' = 'Rock'
);
$args = array(
'labels' = $labels,
'description' = 'Introduzca un nueva entrada en rock',
'public' = true,
'menu_position' = 5,
'supports' = array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' = true,
'hierarchical' = true,
'rewrite' = array('slug' = 'Rock/%genero%', 'with_front' = false),
'query_var' = true,
//'rewrite' = true,
//'publicly_queryable' = false,
);
register_post_type( 'Rock', $args );
}
add_action( 'init', 'my_custom_post_product' );
And here is my loop as it stands now. I still get the 404 error with this code
?php if (have_posts()) : while (have_posts()) : the_post(); ?
header
h2a href="?php the_permalink(); ?" rel="bookmark" title="Permanent Link to ?php the_title_attribute(); ?"?php the_title(); ?/a/h2
ptime datetime="?php echo get_the_date(); ?"?php echo get_the_date(); ?/time. ?php if ( comments_open() ) : ?a class="comment" href="?php the_permalink(); ?#comments"?php comments_number('0 Comments', '1 Comment', '% Comments'); ?/a?php endif; ?/p
/header
?php endwhile; else: ?
p?php _e('Sorry, no posts matched your criteria.'); ?/p
?php endif; ?
nav class="paging"
?php if(function_exists('wp_pagenavi')) : wp_pagenavi(); else : ?
div class="prev"?php next_posts_link('laquo; Previous Posts') ?/div
div class="next"?php previous_posts_link('Next Posts raquo;') ?/div
?php endif; ?
/nav
EDIT 2
I've changed camelcase "Rock" for "rock" and works, but only if change the configuration in Admin > Settings > Reading and set post to display to 5 like the number of posts_per_page (on the loop), but if i need show less post on other page for example post_per_page=3 (e.g. [2], [next]) appears 404 error page.
Is there a way to customize the number if required on other pages?
?php $posts=query_posts($query_string . 'orderby=ascposts_per_page=5'); if (have_posts()) : while (have_posts()) : the_post(); ?
h2a href="?php the_permalink(); ?" rel="bookmark" title="Permanent Link to ?php the_title_attribute(); ?"?php the_title(); ?/a/h2
?$content = get_the_excerpt();
echo substr($content, 0, 200);
global $post;
$text = $post-post_excerpt;?
?php endwhile; else: ?
p?php _e('Sorry, no posts matched your criteria.'); ?/p
?php endif; ?
Topic plugin-wp-pagenavi loop custom-taxonomy custom-post-types Wordpress
Category Web