【发布时间】:2014-09-23 17:40:41
【问题描述】:
我有自定义帖子类型“目录”和自定义分类“目录类别” http://bosfor-alum.ru/catalog/category/okonnye-sistemy/ 插件 PageNavi 显示 404 错误;( 请帮帮我 我使用 wp_query 谢谢 函数.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');
【问题讨论】:
-
我们可以看看你正在使用的循环吗?
-
$query = new WP_Query(array('post_type' => 'catalog', 'meta_key' => 'builder', 'meta_value' => $builder, 'posts_per_page' => $count_n) ); while ( $query->have_posts() ) { $query->the_post(); //这里的内容 if(function_exists('wp_pagenavi')) { wp_pagenavi(array('query' => $query)); } wp_reset_postdata(); ?>
-
希望这可以帮助你...stackoverflow.com/a/31240231/5084291它对我有用!
-
我不确定它是否对你有帮助,但在我的情况下,错误是有一个自定义帖子类型和一个同名的页面。
标签: wordpress http-status-code-404 taxonomy