Support » Fixing WordPress » Custom post type & custom category taxonomy not working

  • Hi, Ive got a custom post type running and made a custom category for it. Everything works great except for the url to the category which I want to show after the post type slug.

    example.com/games (works)
    example.com/games/genre/category (doesn’t work)
    example.com/genre/category (works)

    Here is my code:

    function my_custom_post() {
    	register_post_type( 'games',
    		array(
    			'labels' => array(
    				'name' => __( 'Games' ),
    				'singular_name' => __( 'Game' ),
    			),
    
    		'public' => true,
    		'show_ui' => true,
    		'hierarchical' => false,
    		'has_archive' => true,
    		'capability_type' => 'post',
    		'supports' => array( 'title', 'excerpt', 'thumbnail' ),
    		'taxonomies' => array( 'genre'),
    		'rewrite' => array('slug' => 'games','with_front' => FALSE),
    		)
    	);
    
    }
    
    function my_custom_txonomy() {
       register_taxonomy(
        'games',
        'games_category',
        array(
            'hierarchical' => true,
            'label' => 'Games categories',
            'query_var' => true,
            'rewrite' => array('slug' => 'genre','with_front' => false)
        )
    ); 
    
    } 
    
    add_action('init', 'my_custom_post', 0 );
    add_action('init', 'my_custom_txonomy', 10);

Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Custom post type & custom category taxonomy not working’ is closed to new replies.