Remove parent category from Permalink (6 posts)

  1. Anonymous
    Posted 8 years ago #

    After some considerable trial and error and Googling, I've come to the conclusion that there is no way to remove the parent category from a permalink when using the /%category%/%postname%/ custom structure, correct?

    In other words, if I have a parent category 'apple', a child category of that parent 'pie' and a post in the 'pie' category entitled 'recipe', the permalink will read:


    What I would like to do is have the permalink read only:


    ...but still have the 'pie' category as a child of the 'apple' category. It seems to me that there is no way to do this. Is this correct? Or have I overlooked something?

  2. gulflee
    Posted 7 years ago #

    i have the same question on having the permalink without the child category name: subcategory in wordpress:
    http://example.com/apple/pie/recipe/ -->

    is that posible?

  3. perfectlover
    Posted 7 years ago #

    I am also looking for the answer. I remember there was a plugin to do this but cant find now.

  4. TradingMetro
    Posted 7 years ago #

    I'd like to remove all parent categories altogether.

    So in the first example, it should just show:

    If anyone can find a solution, that'd be great!

  5. mantis108
    Posted 7 years ago #

    There is an older WP 2.3 one called Remove Parents http://wordpress.org/extend/plugins/remove-parents and it seems to work OK in WP 2.7 removing the top level parent but not 2nd or add'l level parents. So, if you're 2 deep, it should work OK for you.

  6. nacholibre
    Posted 7 years ago #

    For WordPress 2.7 or higher
    open wp-includes/category-template.php

    $catlink = str_replace( '%category%', $category_nicename, $catlink );

    add below

    $p = get_category_parents( $category->parent, false, '/', true );
    $catlink = str_replace($p, '', $catlink);

    save and upload

    this little script removes the parent category from Permalink

Topic Closed

This topic has been closed to new replies.

About this Topic