Category in permalink

I have a question about removing a piece in the permalink.

I see that a piece with ‘‘category’’ is now being created, but I don’t want this at all. How do I get this everywhere?

When I’m in the menu I don’t have that, but when I click on the category under a message, a piece of text is added in the permalink.

image

image

Hi Jorn,

this is the default WordPress category slug that is always used unless another is defined. There are several ways to remove /category from the URL, but this would not work in your case, as you don’t use an archive template for your categories, but simple pages.

Removing /category would result in your category archives having the same slug as your pages - and this is not possible because the slug must always be unique (as it is when /category is in front of it).

If I were you, I would create an archive template (valid for all categories), remove the pages that now “represent” your category archives and then try to remove the slug. Then the chances are better that it will work.

Greetings,
timmse

Hi Timmse,

I don’t know how to create such an archive and I don’t really understand what I should do next if ive done that.

What I understand so far is that I should remove the current slug from their pages, or the entire pages and then?

Hi, ok, step by step.

Before you start, disable your caching, clear the caches, and to be on the safe side, make a backup of your site. You can’t go far wrong, but better safe than sorry.

  1. Go to Bricks » Templates and create a new Archive template, Type Archive or edit your existing archive template (seems like there is one already)

You can copy all elements from one of your pages, e.g., from https://ballsonly.nl/women/.
Then, change the dynamic data tag of your page title to {archive_title:context} and remove the term (e.g., Women) from your posts element query under Posts » Query » Terms (include). Then move to Template Settings » Conditions and add Archive and All Archives. Hit save. To test if your newly created archives are working, you can check https://ballsonly.nl/category/food-drinks/, https://ballsonly.nl/category/cars/ and so on.

  1. Change the permalink on every page you’re currently using as you archive templates.

Go to Pages and open every single page (with Gutenberg) that represents one of your categories and extend the permalink to something like “women-2” (so you can go back if something goes wrong).

  1. Remove /category with the option of your choice from this article. Check if https://ballsonly.nl/food-drinks/ works. If so:

  2. You probably need to update your nav menu. To do so, remove all the pages and add your categories instead.

Best regards,
timmse

Hi Timmse,

It all worked till this part! Great :smiley:

What do you mean by remove all pages and add categories? How do i do this? (thnx for all the help so far, very nice!

Hi, it doesn’t work quite right yet, because your links still point to your pages. Shall I have a quick look? I think the access data you sent us still works :slight_smile:

Hi Timmse,

Thats fine by me! Ill wait for your answer.

Hi Jorn,

let me explain what I did:

  1. I set all the pages you used before as “category pages” to draft to avoid conflicts. Feel free to delete them because you don’t need them anymore. All of your categories will now be shown through the archive template (one template to rule them all).

  2. I updated the posts element in your archive template and removed all included terms. You don’t need to include them because the element knows which term it should show (magically). I updated the Category Field to {post_terms_category} as well.

  3. I updated your main nav menu, removed all the page links, and replaced them with category links (see Appearance » Menus).

  4. I extended your permalinks with %category%, so your category is now part of your post links: Top 10 heetste vrouwen van Nederland - BallsOnly. You can remove that if you don’t want that, of course.

Let me know if something is not working. As far as I see, everything’s fine.

Best regards,
timmse

1 Like

Hi Timmse,

Really perfect! I am very satisfied with Bricksbuilder and the support! I’m going to buy the unlimited package one of these days! great guy!

1 Like

I’m glad to hear that! I have just added point 4, I had just forgotten :sweat_smile: