• Hi to everyone.
    I’m reorganizing a pretty large blog with more than 600 posts.

    We have created multiple categories and some of them need to be shown as parent/child in the breadcrumb but not in the permalink.

    It’s a travel blog so one parent category is “Things to do” and have multiple child categories like “Monuments” “Museums” “Churchs”

    So for the post “Saint Peter’s Basilica” the permalink has to be:
    mydomain.com/saint-peters-basilica/
    Bus the breadcrumb should display child and parent categories like this:
    Home / Things to do / Churchs /

    How can I do this?
    Thank you so much in advance

    • This topic was modified 4 years, 5 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    The inclusion of categories in post permalinks is optional. Just pick the “Post name” option in permalink settings. The breadcrumb code can get the related categories from the requested post object with something like wp_get_post_categories((). It’s possible for code to determine parent categories even if they are not explicitly assigned to the post.

    The breadcrumb trail is not part of core WP though. It’s due to your theme or a plugin. I recommend asking through the dedicated support channel of the responsible module how you might accomplish what you want with breadcrumbs.

    Thread Starter Pedro Martinez Saro

    (@elk3rry)

    Thank you so much.
    I’ve already picked the “Post name” option in permaliks but for all subcategories archives the permalinks are

    mydomain.com/parent-category/child-category/

    I’d like to display only last child for archives permalinks. Like this:

    mydomain.com/child-category/

    How do I do that?

    Moderator bcworkz

    (@bcworkz)

    It’d take some custom coding. Use the “category_link” filter to alter the links that WP generates for categories. You can remove the parent slug if there are no redundant child slugs among the various parents. But you need to leave the /category/ element or something similar, or WP will try to find a page called “child-category” and not the taxonomy term.
    https://developer.ww.wp.xz.cn/reference/hooks/category_link/

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Remove parent category from permalink but keep breadcrumbs structure’ is closed to new replies.