Need to display custom taxonomy on single page - not working

I've looked at several posts on here trying to crack this. I think it's simple for someone who knows more. The

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 slug used-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
 |  Show 1 more comment

1 Answer 1

Reset to default 1

I 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);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745586188a4634553.html

相关推荐

  • Need to display custom taxonomy on single page - not working

    I've looked at several posts on here trying to crack this. I think it's simple for someone who knows more. The

    8小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信