WordPress.org

Ready to get started?Download WordPress

Forums

Remove parent category from Permalink (6 posts)

  1. Anonymous
    Unregistered
    Posted 6 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:

    http://example.com/apple/pie/recipe/

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

    http://example.com/pie/recipe/

    ...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
    Member
    Posted 6 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/ -->
    http://example.com/apple/recipe/

    is that posible?

  3. perfectlover
    Member
    Posted 5 years ago #

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

  4. TradingMetro
    Member
    Posted 5 years ago #

    I'd like to remove all parent categories altogether.

    So in the first example, it should just show:
    http://example.com/recipe/

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

  5. mantis108
    Member
    Posted 5 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
    Member
    Posted 5 years ago #

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

    $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