WordPress.org

Support

Support » Plugins and Hacks » Remove Parent Categories from Category URL

Remove Parent Categories from Category URL

Viewing 5 replies - 1 through 5 (of 5 total)
  • I have got exactly the same issue.
    Is it possible to remove the parent category from the url with WordPress 3.1 ?

    Any ideas about this new issue ?

    I finally find a way to change this!

    Put this code in your functions.php fiel :

    add_action( 'init', 'build_taxonomies', 0 );  
    
    function build_taxonomies() {
    
      register_taxonomy( 'category', 'post', array(
    		'hierarchical' => true,
    	 	'update_count_callback' => '_update_post_term_count',
    		'query_var' => 'category_name',
    		'rewrite' => did_action( 'init' ) ? array(
    					'hierarchical' => false,
    					'slug' => get_option('category_base') ? get_option('category_base') : 'category',
    					'with_front' => false) : false,
    		'public' => true,
    		'show_ui' => true,
    		'_builtin' => true,
    	) );
    
    }

    Setting the hierarchical parameter of the rewrite parameter to false does the job perfectly! 🙂

    That worked, but the way it was before I switched to 3.1 was that if you did land on

    http://www.mysite.com/category/parent-1/parent-2/child/

    It would redirect to

    http://www.mysite.com/category/child/

    Thanks for the tip – I love learning.

    awesome dude, just what I was looking for 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Remove Parent Categories from Category URL’ is closed to new replies.