显示筛选的类别列表页面时出现问题。我希望能够只显示当前类别,而不是“我的类别”中的所有帖子。i、 e.www。。。com/mycategories/category-3/只会在分类页面中显示帖子。这是我所拥有的,但它似乎显示了taxonomy-mycategories.php
页
Template page:
<?php
$wp_query = null; $wp_query = $temp;
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query("post_type=business&category_name=" . $_GET["category"] . "&". $catinclude ."&paged=".$paged.\'&showposts=20\');
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php the_title() ?>
<?php endwhile; ?>
functions.php:
/******************
// Business
******************/
function my_custom_post_business() {
$labels = array(
\'name\' => _x( \'business\', \'post type general name\' ),
\'singular_name\' => _x( \'business\', \'post type singular name\' ),
\'add_new\' => _x( \'Add New\', \'book\' ),
\'add_new_item\' => __( \'Add New business\' ),
\'edit_item\' => __( \'Edit business\' ),
\'new_item\' => __( \'New business\' ),
\'all_items\' => __( \'All business\' ),
\'view_item\' => __( \'View business\' ),
\'search_items\' => __( \'Search business\' ),
\'not_found\' => __( \'No business found\' ),
\'not_found_in_trash\' => __( \'No business found in the Trash\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'business\'
);
$args = array(
\'labels\' => $labels,
\'description\' => \'Holds our business and business specific data\',
\'public\' => true,
\'hierarchical\' => true,
\'show_ui\' => true,
\'show_in_nav_menus\' => true,
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'excerpt\', \'comments\' ),
\'has_archive\' => true,
\'rewrite\' => array(
\'slug\' => \'business\',
\'with_front\' => false
),
//\'taxonomies\' => array(\'category\'),
);
register_post_type( \'business\', $args );
}
add_action( \'init\', \'my_custom_post_business\' );
/** add categories for custom post type */
add_action( \'init\', \'build_taxonomies\', 0 );
function build_taxonomies() {
register_taxonomy( \'mycategories\', \'business\', array( \'hierarchical\' => true, \'label\' => \'Business Categories\', \'query_var\' => true, \'rewrite\' => true ) );
}