WordPress.org

Ready to get started?Download WordPress

Forums

Url mapping - modified loop to sort custom post types by taxonomy (2 posts)

  1. gpspake
    Member
    Posted 1 year ago #

    I'm trying to do exactly what wordpress already does with posts and categories. I'm very close to having this working but I'm running in to a wall here. It seems to me that this should be a standard feature and this is critical to full functionality of custom post types.

    I have created a custom post type called 'requests' that has a custom taxonomy 'request-categories'. I've created a template with a modified loop that allows me to view my custom post type in a certain 'request-category' for instance 'electronics-requests'.

    The loop works if I manually change the args for post type and taxonomy but, in order for it to be usable, I need to figure out how to deal with the urls so that mysite.com/requests/request-category/electronics-request will modify the loop in such a way that will provide the expected results.

    The way I see it, mysite.com/requests will be an actual page, while the request-category and electronics-request portions of the url would be assigned to the appropriate variables in the loop. Which seems easy enough but I don't know how to keep wordpress from 404ing.

    Does anyone with more knowledge about how WP handles urls have any suggestions?

  2. gpspake
    Member
    Posted 1 year ago #

    Update: Figured it out!

    Okay, so it turns out that what I'm trying to do actually is available in WordPress but it requires a very odd and unintuitive trick to get it to work. A while back, when I was working on a multisite installation and we couldn't get pretty permalinks to work. One day, I stumbled across this blog post. Ultimately what it said was that after you have modified your permalink structure in the multisite settings, you need to click on permalinks in the menu... that's it, you don't do anything or change an settings, you just go to that page. Something happens when you go to the permalinks page in the admin menu that seems to fix a lot of issues with permalinks and when it popped in to my head a few minutes ago I decided to try it. IT WORKED. It's the weirdest fix I think I've ever found but this will probably be the fourth time that it's solved permalink issues for me. I've spent 2 days trying to figure this out.

Topic Closed

This topic has been closed to new replies.

About this Topic