Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Nickvdp on "issues with custom post type with custom taxonomy hierarchy"

$
0
0

Hi all,

I am trying to set up my WP install with the custom post type 'dm_tool' and hierarchical custom taxonomy 'tool_type'.

What I am trying to achieve is the following:
domain.com/tools showing the custom post type archive page
domain.com/tools/books showing a books archive page
domain.com/tools/books/title showing the single for a book

I have been searching Google for three days now but I can't find a way to make it work. I have the following in my functions.nl:

$args = array(
			'hierarchical' => true,
			'labels' => $labels,
			'query_var' => true,
			'rewrite' => array('slug' => 'tools', 'hierarchical' => true)
			);

	/* Register the Custom taxonomy */
	register_taxonomy('tool_type',	array('dm_tool'), $args);

	/* Custom Post Type */
    $labels = array(
        'name' => _x('Tools', 'post type general name'),
        'singular_name' => _x('Tool', 'post type singular name')
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
    	'taxonomies' => array('tool_type'),
        'menu_position' => null,
        'supports' => array('title','editor','thumbnail', 'excerpt'),
        'rewrite' => array(
            'slug' => 'tools/%tool_type%',
            'with_front' => false,

        ),
        'has_archive' => 'tools'
    );

    register_post_type( 'dm_tool' , $args );

domain.com/tools shows archive-dm_tool.php and domain.com/tools/book/title shows single-dm_tool. domain.com/tools/books shows a default page template. Why is this?

Any help/suggestion is greatly appreciated..


Viewing all articles
Browse latest Browse all 8245

Trending Articles