404错误wordpress PageNavi自定义分类

时间:2014-07-31 16:48:31

标签: wordpress http-status-code-404 taxonomy

我有自定义帖子类型'目录'和自定义分类' catalog_category' http://bosfor-alum.ru/catalog/category/okonnye-sistemy/插件PageNavi向我显示404错误;( 请帮帮我 我用wp_query 谢谢 的functions.php

// Register Custom Post Type
function catalog() {
$labels = array(
    'name'                => _x( 'Товар', 'Post Type General Name', 'catalog' ),
    'singular_name'       => _x( 'Товар', 'Post Type Singular Name', 'catalog' ),
    'menu_name'           => __( 'Каталог', 'catalog' ),
    'parent_item_colon'   => __( 'Вложенный:', 'catalog' ),
    'all_items'           => __( 'Все', 'catalog' ),
    'view_item'           => __( 'Посмотреть', 'catalog' ),
    'add_new_item'        => __( 'Добавить', 'catalog' ),
    'add_new'             => __( 'Добавить', 'catalog' ),
    'edit_item'           => __( 'Изменить', 'catalog' ),
    'update_item'         => __( 'Обновить', 'catalog' ),
    'search_items'        => __( 'Найти', 'catalog' ),
    'not_found'           => __( 'Не найдено', 'catalog' ),
    'not_found_in_trash'  => __( 'Не найдено', 'catalog' ),
);
$args = array(
    'label'               => __( 'catalog', 'catalog' ),
    'description'         => __( 'Описание', 'catalog' ),
    'labels'              => $labels,
    'supports'            => array( 'title', 'editor', 'thumbnail', 'custom-fields', ),
    'hierarchical'        => false,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => true,
    'publicly_queryable'  => true,
    'capability_type'     => 'page',
);
register_post_type( 'catalog', $args );

}

// Hook into the 'init' action
add_action( 'init', 'catalog', 0 ); 
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
    'name'              => _x( 'Категории', 'taxonomy general name' ),
    'singular_name'     => _x( 'Категория', 'taxonomy singular name' ),
    'search_items'      => __( 'Найти' ),
    'all_items'         => __( 'Все' ),
    'parent_item'       => __( 'Вложенность' ),
    'parent_item_colon' => __( 'Вложенность:' ),
    'edit_item'         => __( 'Изменить' ),
    'update_item'       => __( 'Сохранить' ),
    'add_new_item'      => __( 'Добавить' ),
    'new_item_name'     => __( 'Создать' ),
    'menu_name'         => __( 'Категории' ),
);

$args = array(
    'hierarchical'      => true,
    'labels'            => $labels,
    'show_ui'           => true,
    'show_admin_column' => true,
    'query_var'         => true,
    'rewrite' => array( 'slug' => 'catalog/category', 'with_front' => false,    'hierarchical' => true)
);

register_taxonomy( 'catalog_category', array( 'catalog' ), $args );
add_action('admin_init', 'flush_rewrite_rules');

2 个答案:

答案 0 :(得分:0)

$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;

并在查询中添加:

$query = new WP_Query( array( 'paged' => $paged, 'post_type' => 'catalog', 'meta_key' => 'builder', 'meta_value' => $builder, 'posts_per_page' => $count_n) )

答案 1 :(得分:0)

因为,'分页'未指定参数,以获取下一组帖子。 您可以使用以下代码

if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
else { $paged = 1; }

$query = new WP_Query( array( 'posts_per_page' => $count_n, 'paged' => $paged, 'post_type' => 'catalog', 'meta_key' => 'builder', 'meta_value' => $builder) );