admin管理员组文章数量:1023782
I've looked at several posts on here trying to crack this. I think it's simple for someone who knows more. The details:
Theme: Custom theme built on Roots starter
WP: 3.8.1
Custom Post Type: pre_owned_cars
My custom post types work well - I'm used to doing those. The taxonomy however is tripping me up. I have it working with the code in my functions.php file, but I can't figure out how to display a taxonomy. I've created taxonomy.php and updated permalinks.
Here's my functions.php code for the taxonomy - I'm trying to name the taxonomy "type":
// add tags to pages
add_action( 'init', 'register_taxonomy_types' );
function register_taxonomy_types() {
$labels = array(
'name' => _x( 'Types', 'types' ),
'singular_name' => _x( 'Type', 'types' ),
'search_items' => _x( 'Search Types', 'types' ),
'popular_items' => _x( 'Popular Types', 'types' ),
'all_items' => _x( 'All Types', 'types' ),
'parent_item' => _x( 'Parent Type', 'types' ),
'parent_item_colon' => _x( 'Parent Type:', 'types' ),
'edit_item' => _x( 'Edit Type', 'types' ),
'update_item' => _x( 'Update Type', 'types' ),
'add_new_item' => _x( 'Add New Type', 'types' ),
'new_item_name' => _x( 'New Type', 'types' ),
'separate_items_with_commas' => _x( 'Separate types with commas', 'types' ),
'add_or_remove_items' => _x( 'Add or remove Types', 'types' ),
'choose_from_most_used' => _x( 'Choose from most used Types', 'types' ),
'menu_name' => _x( 'Types', 'types' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'show_admin_column' => false,
'hierarchical' => true,
'rewrite' => array(
'slug' => 'used-cars',
'with_front' => true,
'hierarchical' => true
),
'query_var' => true
);
register_taxonomy( 'types', array('pre-owned-cars'), $args );
}
Any help GREATLY appreciated!
I've looked at several posts on here trying to crack this. I think it's simple for someone who knows more. The details:
Theme: Custom theme built on Roots starter
WP: 3.8.1
Custom Post Type: pre_owned_cars
My custom post types work well - I'm used to doing those. The taxonomy however is tripping me up. I have it working with the code in my functions.php file, but I can't figure out how to display a taxonomy. I've created taxonomy.php and updated permalinks.
Here's my functions.php code for the taxonomy - I'm trying to name the taxonomy "type":
// add tags to pages
add_action( 'init', 'register_taxonomy_types' );
function register_taxonomy_types() {
$labels = array(
'name' => _x( 'Types', 'types' ),
'singular_name' => _x( 'Type', 'types' ),
'search_items' => _x( 'Search Types', 'types' ),
'popular_items' => _x( 'Popular Types', 'types' ),
'all_items' => _x( 'All Types', 'types' ),
'parent_item' => _x( 'Parent Type', 'types' ),
'parent_item_colon' => _x( 'Parent Type:', 'types' ),
'edit_item' => _x( 'Edit Type', 'types' ),
'update_item' => _x( 'Update Type', 'types' ),
'add_new_item' => _x( 'Add New Type', 'types' ),
'new_item_name' => _x( 'New Type', 'types' ),
'separate_items_with_commas' => _x( 'Separate types with commas', 'types' ),
'add_or_remove_items' => _x( 'Add or remove Types', 'types' ),
'choose_from_most_used' => _x( 'Choose from most used Types', 'types' ),
'menu_name' => _x( 'Types', 'types' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'show_admin_column' => false,
'hierarchical' => true,
'rewrite' => array(
'slug' => 'used-cars',
'with_front' => true,
'hierarchical' => true
),
'query_var' => true
);
register_taxonomy( 'types', array('pre-owned-cars'), $args );
}
Any help GREATLY appreciated!
Share Improve this question asked Jan 30, 2014 at 1:47 Theater ElevenTheater Eleven 111 bronze badge 6 | Show 1 more comment1 Answer
Reset to default 1I don't think the taxonomy is registered with your custom post type.
Please check this or may be i'm wrong:
if your custom post type is registered with this name: 'pre_owned_cars'
, your taxonomy registration is incorrect: it should be register_taxonomy('types', array('pre_owned_cars'), $args);
I've looked at several posts on here trying to crack this. I think it's simple for someone who knows more. The details:
Theme: Custom theme built on Roots starter
WP: 3.8.1
Custom Post Type: pre_owned_cars
My custom post types work well - I'm used to doing those. The taxonomy however is tripping me up. I have it working with the code in my functions.php file, but I can't figure out how to display a taxonomy. I've created taxonomy.php and updated permalinks.
Here's my functions.php code for the taxonomy - I'm trying to name the taxonomy "type":
// add tags to pages
add_action( 'init', 'register_taxonomy_types' );
function register_taxonomy_types() {
$labels = array(
'name' => _x( 'Types', 'types' ),
'singular_name' => _x( 'Type', 'types' ),
'search_items' => _x( 'Search Types', 'types' ),
'popular_items' => _x( 'Popular Types', 'types' ),
'all_items' => _x( 'All Types', 'types' ),
'parent_item' => _x( 'Parent Type', 'types' ),
'parent_item_colon' => _x( 'Parent Type:', 'types' ),
'edit_item' => _x( 'Edit Type', 'types' ),
'update_item' => _x( 'Update Type', 'types' ),
'add_new_item' => _x( 'Add New Type', 'types' ),
'new_item_name' => _x( 'New Type', 'types' ),
'separate_items_with_commas' => _x( 'Separate types with commas', 'types' ),
'add_or_remove_items' => _x( 'Add or remove Types', 'types' ),
'choose_from_most_used' => _x( 'Choose from most used Types', 'types' ),
'menu_name' => _x( 'Types', 'types' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'show_admin_column' => false,
'hierarchical' => true,
'rewrite' => array(
'slug' => 'used-cars',
'with_front' => true,
'hierarchical' => true
),
'query_var' => true
);
register_taxonomy( 'types', array('pre-owned-cars'), $args );
}
Any help GREATLY appreciated!
I've looked at several posts on here trying to crack this. I think it's simple for someone who knows more. The details:
Theme: Custom theme built on Roots starter
WP: 3.8.1
Custom Post Type: pre_owned_cars
My custom post types work well - I'm used to doing those. The taxonomy however is tripping me up. I have it working with the code in my functions.php file, but I can't figure out how to display a taxonomy. I've created taxonomy.php and updated permalinks.
Here's my functions.php code for the taxonomy - I'm trying to name the taxonomy "type":
// add tags to pages
add_action( 'init', 'register_taxonomy_types' );
function register_taxonomy_types() {
$labels = array(
'name' => _x( 'Types', 'types' ),
'singular_name' => _x( 'Type', 'types' ),
'search_items' => _x( 'Search Types', 'types' ),
'popular_items' => _x( 'Popular Types', 'types' ),
'all_items' => _x( 'All Types', 'types' ),
'parent_item' => _x( 'Parent Type', 'types' ),
'parent_item_colon' => _x( 'Parent Type:', 'types' ),
'edit_item' => _x( 'Edit Type', 'types' ),
'update_item' => _x( 'Update Type', 'types' ),
'add_new_item' => _x( 'Add New Type', 'types' ),
'new_item_name' => _x( 'New Type', 'types' ),
'separate_items_with_commas' => _x( 'Separate types with commas', 'types' ),
'add_or_remove_items' => _x( 'Add or remove Types', 'types' ),
'choose_from_most_used' => _x( 'Choose from most used Types', 'types' ),
'menu_name' => _x( 'Types', 'types' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'show_admin_column' => false,
'hierarchical' => true,
'rewrite' => array(
'slug' => 'used-cars',
'with_front' => true,
'hierarchical' => true
),
'query_var' => true
);
register_taxonomy( 'types', array('pre-owned-cars'), $args );
}
Any help GREATLY appreciated!
Share Improve this question asked Jan 30, 2014 at 1:47 Theater ElevenTheater Eleven 111 bronze badge 6- 1 Is the taxonomy showing up in the admin area correctly? – Andrew Bartel Commented Jan 30, 2014 at 1:56
-
describe "not working". you've named your taxonomy
types
, and given it the slugused-cars
, so a single term will be/used-cars/term-name/
. have you created a term and assign it to a post? note that taxonomies aren't like post types- there is no single archive, it's archives for each term. – Milo Commented Jan 30, 2014 at 2:10 - Okay, so the slug combined with the term is generating a page, but instead of showing the CPTs with this term or taxonomy, it's printing this on the page: wp_list_categories( array( 'taxonomy' => 'register_taxonomy_type' ) ); wp_list_categories( array( 'taxonomy' => 'register_taxonomy_type' ) ); (thanks for the help!) – Theater Eleven Commented Jan 30, 2014 at 2:41
- Per the last comment, your problem appears to be with your theme template-- a PHP syntax error I'd guess. Post the code for that template. – s_ha_dum Commented Jan 30, 2014 at 3:49
- <?php while (have_posts()) : the_post(); ?> wp_list_categories( array( 'taxonomy' => 'register_taxonomy_type' ) ); <?php endwhile; ?> – Theater Eleven Commented Jan 30, 2014 at 4:22
1 Answer
Reset to default 1I don't think the taxonomy is registered with your custom post type.
Please check this or may be i'm wrong:
if your custom post type is registered with this name: 'pre_owned_cars'
, your taxonomy registration is incorrect: it should be register_taxonomy('types', array('pre_owned_cars'), $args);
本文标签: Need to display custom taxonomy on single pagenot working
版权声明:本文标题:Need to display custom taxonomy on single page - not working 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745586185a2157608.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
types
, and given it the slugused-cars
, so a single term will be/used-cars/term-name/
. have you created a term and assign it to a post? note that taxonomies aren't like post types- there is no single archive, it's archives for each term. – Milo Commented Jan 30, 2014 at 2:10