• Gauri

    (@goldengalaxy)


    Hi Team,

    I have a specific scenario –
    I created a custom category say Fruit Basket. So the slug created was fruit-basket in the category page URL.
    But I want the category URL to be https://www.xyz.com/fruit instead of https://www.xyz.com/fruit-basket
    I cannot modify the slug since there are other things mapped to the slug and changing the slug would break the code.
    Please suggest how to achieve this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • A plugin like Redirection could help you redirect the old slug to the new one.

    Or you could manually build the same functionality with some code.

    Thread Starter Gauri

    (@goldengalaxy)

    Hi Nigel,

    Thank you for your response.

    I tried to use the plugin and added a redirect. But it goes to 404 page.

    Is this because I am having template file for that category?

    Thread Starter Gauri

    (@goldengalaxy)

    Any help here?
    I really want this to work.

    It’s not clear what you mean by

    I cannot modify the slug since there are other things mapped to the slug and changing the slug would break the code.

    Can you give an example or more?

    My thinking was you can edit the category to change the slug, so ‘/fruit-basket/’ becomes ‘/fruit/’. After changing the slug, https://yoursite.com/fruit-basket/ becomes a broken link so you need to create a redirect from /fruit-basket/ to /fruit/ so that the link is not broken anymore. A redirect can be created using a plugin like the one above. or using a couple of lines of code in your server config files.

    • This reply was modified 3 years, 8 months ago by Nigel M Rodgers. Reason: edite line "A redirect can be created using a plugin like the one above"
    Thread Starter Gauri

    (@goldengalaxy)

    Hi Nigel,
    By this –

    I cannot modify the slug since there are other things mapped to the slug and changing the slug would break the code.

    I meant that if I change the slug there are functionalities that would not work since there are other systems (e.g. oracle cloud) integrated/mapping and use the slug as a key.
    And so I wanted a solution where I could achieve desired URL path without changing the slug.
    Do you know of any such workaround?

    Alright. Then renaming the slug and a redirect will work. You need to do both. In the above tries you did one or the other.

    Go into wp-admin > Posts > categories. Rename the slug ‘fruit-basket’ to fruit. Then create a 301 redirect either using a plugin above or a server config file (.htaccess for Apache, or the Nginx config).

    Test it with your integrated systems. It will work. This is the exact situation a redirect was created for.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Change custom category URL’ is closed to new replies.