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

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #43908
    danidani
    Participant

    I am trying to create this structure of my information pages:

    Archive page:
    /information

    Categories:
    /information/category1
    /information/category2
    etc

    When 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?
    Thanks

    #43929
    PeterPeter
    Moderator

    Hello 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.

    #43939
    Tobias HaasTobias Haas
    Participant

    Hi 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/EXVCYj8d

    CPT: Taxonomy
    https://pastebin.com/9DVMgV65

    #43945
    PeterPeter
    Moderator

    Hello Tobias,

    It is different from my description. You are using Custom rewrite slug, not Custom archive slug for the CPT. I also don't understand why you add the team to Custom rewrite slug option while the CPT slug is team.
    If you add information for CPT Custom archive slug and Custom 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.

    #43946
    Tobias HaasTobias Haas
    Participant

    Hey Peter,

    Ohhh sorry... I'm only seeing it now. 🙁 It was late yesterday.

    I'm trying the following.

    CPT = Team
    Tax = Team Category

    my-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

    #43949
    danidani
    Participant

    To be more precis, this is how it is now:

    the archive page works fine:
    domain.com/cpt-slug

    the posts work fine too:
    domain.com/cpt-slug/post

    but I can't make the categories work:
    domain.com/cpt-slug/category

    What can I do to make the categories work?

    #43950
    danidani
    Participant

    I have used the custom rewrite for both CPT and category
    Both are using "information"

    #43960
    Anh TranAnh Tran
    Keymaster

    Hi,

    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 and register_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.

    #43968
    Tobias HaasTobias Haas
    Participant

    Hey 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.

    #43973
    Tobias HaasTobias Haas
    Participant

    Ultimately, 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?

    #44009
    PeterPeter
    Moderator

    Hello 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

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.