Custom Post Type and Taxonomy pagination 404 error

蓝咒 提交于 2019-12-02 09:46:54
Jigs P

May be you need to enable search to enable pagination

While declaring custom taxonomy you should disable search excluding.

exclude_from_search => false

This fixed my problem. I have very hard time to find this solution. Hope this helps everyone.

My code is:

register_post_type( 'lifestyle',
                array( 
                'label' => __('Lifestyle', 'tmi'), 
                'public' => true, 
                'show_ui' => true,
                'show_in_nav_menus' => true,
                'rewrite' => true,
                'hierarchical' => true,
                'menu_position' => 5,
                'exclude_from_search' =>false,
                'supports' => array(
                                     'title',
                                     'editor',
                                     'thumbnail',
                                     'excerpt',
                                     'revisions')
                    ) 
                );

    register_taxonomy('lifestylecat', __('lifestyle', 'tmi'),array('hierarchical' => true, 'label' =>  __('Categories', 'tmi'), 'singular_name' => __('Category', 'tmi'))
    );
// get the global query object
global $wp_query;
// get the correct page var
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// create the page argument
$args=  array('paged'=> $paged);
// merge the page argument array with the original query array
$args = array_merge( $wp_query->query, array( 'post_type' => 'equipment' ) );
// Re-run the query with the new arguments
query_posts( $args );
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!