Skip Navigation

[Resolved] Custom URL rewriting and WordPress endpoints

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Jackie 5 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1207075
pce catalog data relationships.png

Hi there,

This question is absolutely not a Types issue and therefore I do not expect Toolset Support to supply an answer, but I figured I'd ask the experts anyway. My question involves creating an artificial URL structure and routing it to the correct custom post.

Here's some background information:

+ I'm building a course catalog for a continuing education department at an art college. The hierarchy of information looks like this: catalog > department > course > section > faculty. All objects are custom post types, except "department" which is a custom taxonomy. I've attached a diagram to illustrate the relationships (pce catalog data relationships.png).

+ Multiple catalogs can be published simultaneously (for example, there will be overlap between when the Spring 2019 catalog is active and Summer 2019 launches).

+ A section is an instance of a course. This reduces data redundancy when the same course runs two or three times in a given catalog (and across multiple catalogs).

+ Right now, the permalink structure of a section looks like this:

hidden link

Note: "section" is the custom post type prefix. "handmade-books-01" is the slug of the section.

+ The user-facing hierarchy that I wish to express looks like this: catalog > section > section number. The permalink structure that I want to use would look like this:

hidden link

...where "spring-2019" is the catalog.
...where "handmade-books" is the slug of the course (NOT the section).
...where "01" is the section number.

+ Based on the desired URL above, I want to do a dynamic lookup of the correct section and display it (and to be clear, not forward users to it, which I could easily do with mod_rewrite—I want users to be able to bookmark clearly articulated URLs).

+ A bonus permalink structure would also let me add the name (slug) of a faculty member onto the end of the web address, like so:

hidden link
hidden link

--

I've done a bit of research into add_rewrite_rule() and add_rewrite_endpoint(), but I'm having difficulty with the implementation. The best guide I've found is at https://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/.

Are you able to offer any guidance?

Thank you!

Saul

#1207190

Hi, unfortunately you are correct in that we don't offer this type of permalink customization assistance. Custom rewrite rules are tricky business, even for advanced developers, and tend to require frequent modification as the site's content grows. Toolset sticks to the standard WordPress URL structures for archives and custom post types, and custom directory structures, hierarchies, and so forth are outside the scope of support we provide here. You can reach out to an independent developer on the contractors form if you'd like to get some professional assistance implementing your own custom rules: https://toolset.com/contractors

You could also try a 3rd-party permalink customization plugin. If you need assistance getting information from the post relationships API to supply to a 3rd-party plugin, I'll be glad to help.

#1207219

That's what I expected to hear. Thanks, Christian!