Rewrite permalink of CPT taxonomy to equal of archive page
Support › MB Custom Post Type › Rewrite permalink of CPT taxonomy to equal of archive page
- This topic has 10 replies, 4 voices, and was last updated 1 year, 4 months ago by
Peter.
-
AuthorPosts
-
November 24, 2023 at 8:23 PM #43908
dani
ParticipantI am trying to create this structure of my information pages:
Archive page:
/informationCategories:
/information/category1
/information/category2
etcWhen doing this neither my posts or categories can be found (404)
This is completely doable in ACF, but i can't make it work in Meta Box.
Any ideas?
ThanksNovember 26, 2023 at 9:08 AM #43929Peter
ModeratorHello Dani,
For the taxonomy: You can edit the custom taxonomy > Advanced tab > Custom rewrite slug > Add the rewrite slug "information" > Save changes.
For the CPT: You can edit the CPT > Advanced tab:
- Enable option: Has archive
- Custom archive slug: information
- Save changes.and re-save permalink settings. It works correctly on my demo site.
November 27, 2023 at 5:28 AM #43939Tobias Haas
ParticipantHi Peter,
I have the same problem, I also get a 404 on the category page. The CPT archive is fine.I configured it the way you described. See Pastebin links.
I also tested it with ACF and it worked straight away.
CPT: Team
https://pastebin.com/EXVCYj8dCPT: Taxonomy
https://pastebin.com/9DVMgV65November 27, 2023 at 10:37 PM #43945Peter
ModeratorHello Tobias,
It is different from my description. You are using
Custom rewrite slug
, notCustom archive slug
for the CPT. I also don't understand why you add theteam
toCustom rewrite slug
option while the CPT slug isteam
.
If you addinformation
for CPTCustom archive slug
andCustom rewrite slug
for custom taxonomy, it works properly.Also, Meta Box Custom Post Types and Taxonomies just helps you to register the CPT and taxonomies with UI. It passes the arguments to the WordPress function register_post_type() and register_taxonomy(). So if you see an issue with CPT and taxonomies, it actually is a WordPress issue.
November 27, 2023 at 10:56 PM #43946Tobias Haas
ParticipantHey Peter,
Ohhh sorry... I'm only seeing it now. 🙁 It was late yesterday.
I'm trying the following.
CPT = Team
Tax = Team Categorymy-domain.com/team/tax/cpt-post
It is a team page of a company which is divided into different departments by the taxonomy.
Working Example with ACF
https://acf.tobiashaas.dev/team/The Numbers are my Taxonomy
November 28, 2023 at 1:14 AM #43949dani
ParticipantTo be more precis, this is how it is now:
the archive page works fine:
domain.com/cpt-slugthe posts work fine too:
domain.com/cpt-slug/postbut I can't make the categories work:
domain.com/cpt-slug/categoryWhat can I do to make the categories work?
November 28, 2023 at 3:25 AM #43950dani
ParticipantI have used the custom rewrite for both CPT and category
Both are using "information"November 29, 2023 at 5:48 PM #43960Anh Tran
KeymasterHi,
It's confusing URL structure. If a user access
domain.com/information/security
, is that a post or is that a category? We always don't recommend people doing that. Even if it works in some cases, it will be bad for performance, cause WP need to process through all posts and also terms.FYI: We don't process or generate the rewrite rules. We simply pass all the parameters to WordPress's
register_post_type
andregister_taxonomy
functions. I don't think it works if you use code directly. It's mostly how to deal with the way WP handle rewrite rules than the plugin. I'll check more closely.November 30, 2023 at 5:37 AM #43968Tobias Haas
ParticipantHey Anh,
Thank you very much for your contribution and the helpful information.
I learned something new again.That's my structure
mydomain.com/cpt/category/
mydomain.com/cpt/cpt-post/How would you best implement this structure?
I have 80 employees who I display on the website on different category archive pages.I don't need the CPT archive and I don't use CPT posts either.
CPT = Employee
This is how it is currently implemented.
https://kpzwei.tobiashaas.dev/team/aerzte/If you have a more efficient solution, I'd be happy to learn about it.
November 30, 2023 at 6:59 PM #43973Tobias Haas
ParticipantUltimately, I don't need the CPT slug or any posts. I only need category archive pages with the categorized posts.
So I can deactivate "has archive" in the CPT.
Can I also deactivate single posts and only drag them into the Archive category using Dynamic Data?December 4, 2023 at 10:23 PM #44009Peter
ModeratorHello Tobias,
I tested this case with ACF post type and it doesn't work, like Meta Box. So it is the WordPress issue, not Meta Box or ACF. If you want to have the same slug for CPT and taxonomy, you might need to use some custom code to rewrite the rules. Please follow this topic https://stackoverflow.com/questions/49807692/custom-post-type-and-taxonomy-using-same-slug-with-rewrite
-
AuthorPosts
- You must be logged in to reply to this topic.