• Resolved baldidiot

    (@baldidiot)


    I’ve tested this so I know it’s physically possible, but I’m more wondering if it’s a bad idea for any reason.

    Basically can we have two post types (let’s call them new and old) that both use the same custom rewrite slug (call it /list/).

    Eg:

    /new/post-a/ = /list/post-a/
    /old/post-b/ = /list/post-b/

    The two types appear in different lists so we were thinking it would be easier to separate them like this rather than rely on field based filtering.

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

    (@tw2113)

    The BenchPresser

    Yes, it would be a bad idea because WordPress isn’t going to guaranteed know what you’re intending to query for. It uses the “list” from the URL to be parsed as the post type slug. When the rewrite field is used, it has a mapped item to go to to say “ok, it’s the ‘new’ post type”. If you mix these together between two, then you may have a post of “post-b” in the “old” post type slug, but WP interprets that it should look in the “new” post type. “/new/post-b/” isn’t going to exist, because it’s over in “/old/post-b” and you’ll get a WordPress 404 error for “no posts found”.

    It’d probably be easier to make the URL for “/list/” archives just query from both post types instead of just one or the other. This could remove the need for the matching rewrite slugs, and still show all the same data. Something to consider.

    Thread Starter baldidiot

    (@baldidiot)

    Ok, understood – thanks!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Two post types with the same custom rewrite slug’ is closed to new replies.