Search code examples
wordpress.htaccessurl-rewritingcustom-post-typepermalinks

Wordpress custom permalinks


I've been working on my wordpress permalinks for a couple of days and can't seem to figure out how to get them to work properly.

Here is the simple version of what i have and what i'm trying to achieve

I have 5 different categories (home, sports, beauty, arts, food)

I have 3 types of posts (post, pages, events(custom))

Each post_type can and will be associated to only 1 category

Here is what I would like to get in terms of permalinks

site.com/%category% = a different page for each caetgory (not an archieve)
site.com/%category%/%post_type% = archive listing of post_type
site.com/%category%/%post_type%/%post% = single of post

site.com/%category%/%page_slug% = the contents of a page

When i look at the rewriterules that are being applied i get close but it doens't include my category in the rewrite part

%category%/event//?$    index.php?post_type=event

Any help to get this working would be greatly appreciated. Thanks


Solution

  • I manage to solve my issue and create the permalinks the way I wanted.

    I created my post types like I wanted but I had to put a lot of if/else statement in my header to properly manage my pages and post type to ensure that the right page was being displayed.

    It was quite the headache to finally find a structure that worked but in the end I managed. If I ever have to build a similar structure I hope I can think of a better solution.