• Resolved Chris

    (@osiak)


    Hello,
    is it possible to configure my CPT so that I can achive all of the following options:
    1. Show all CPT posts with the CPT name in front: domain.com/cpt_name/post_name;
    2. Create a page with the CPT slug: domain.com/cpt_name;
    3. Create child pages under the CPT name: domain.com/cpt_name/child_page.
    I managed of course to achive #1 and #2, but #3 not. Any way to do this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    1. Are you talking about in terms of the permalink, or the content seen when visiting specific permalinks? Cause that structure should already be out of box when viewing one post in the post type.

    2. Potentially with archive set to false, though I typically advise against it and I am pretty sure I do page slug exists checks when registering a post type and throw an error when the page already exists with a matching slug.

    3. You’d need to set the post type to hierarchical to get parent/child relationship ability.

    Thread Starter Chris

    (@osiak)

    Hello Michael,
    I’m talking about the permalink structure.
    Here are my CPT settgins:
    – has archive: false;
    – hierarchical: true;
    – rewrite: true;
    – with front: false;
    – quyery var: true.
    With these settings I’m able to achieve a normal permalink structure for CPT posts (domain.com/cpt-name/post-slug) and the page with the CPT name as slug also works (domain.com/cpt-name). However adding a new page and assigning page “cpt-name” as parent throws a 404 error (eg. domain.com/cpt-name/child-page).

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    when you say “page” do you mean a new entry from the “page” post type that comes with WP by default? or a new entry in the custom post type?

    What happens when you rename the part from question 2 to something else, does the rest work? I am curious if WP is interpreting parent/child from the wrong post type.

    Thread Starter Chris

    (@osiak)

    When I say “page” I mean a regular page created from the Page menu, not an entry under the given CPT.
    Renaming this page does not help the 404 error. What does help is changing the settgin “rewrite” to false – then my child page works well, however my CPTs permialinks change their structure to domain.com/?cpt-name=cpt-post-slug

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    at this point it sounds like you’re trying potentially, or unintentionally mixing page permalinks with post type permalinks, which WP isn’t going to know about or understand out of box.

    All reasons why I encourage against pages that have slugs that match post types.

    Thread Starter Chris

    (@osiak)

    Intentionally in this case ??
    Any recommendations on this? I assume the plugin does not provide such settings. I assume there needs to be some custom rewrite rules for the child pages, right?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I can’t recall ever seeing permalink parts mix like this and work, and don’t have any great links to tutorials that may help achieve it, to be honest.

    CPTUI’s primary purpose is to provide a UI for the arguments for both register_post_type and register_taxonomy functions. If a detail takes more than customized arguments for those functions, then CPTUI is only part of the overall solution.

    Rewrites aren’t fun, but parts of me definitely want to try and get better with them. They’re also quite complex deep down.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Posts and child pages under CPT slug?’ is closed to new replies.