• Can two or more CPT share the same base url? I have two event CPT (internal and external events with very different fields and look&feel), but I want to have all events in /agenda/<event-name> (each type with its own template)

    Is this possible?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    No, but there is a possibility I may be wrong. You may want to setup a test to be sure. I suspect the same template will be loaded no matter which CPT is requested based on the /agenda/ portion alone.

    If it’s that important, perhaps you could use a dual purpose CPT which styles content based on an initial selection of a field in the post edit form.

    Thread Starter iuttu

    (@iuttu)

    WP templates are loaded based on queried elements. If you have this rule:
    – /agenda/([^/]+) => index.php?even=$matches[1]

    /agenda/example url will try to load single-event.php template (if event “example” is found). If single-event.php doesn’t exists, it’ll try single.php. If single.php bla bla bla…

    I could use the same CPT and select a template for each type, yes. But this two event types are so so different (type 1 has 200 fields and type 2 has 3) that I think it’s not a good idea to use the same CPT.

    Moderator bcworkz

    (@bcworkz)

    200 to 3! Different CPTs for sure. I had the wrong sort of template in mind, something like taxonomy-agenda.php would always be loaded for an archive-like listing. But for single templates such as single-internal.php, they will be loaded according to the CPT regardless of the taxonomy. Apologies for my confusion.

    Thread Starter iuttu

    (@iuttu)

    Yes… “internal events” has a lot of information (really A LOT). External has just date, place and category =/

    Thank you very much bcworkz 😉

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘CPT shared url’ is closed to new replies.