Forums

One custom taxonomy and multiple custom post types listed separately (2 posts)

  1. wp_juan
    Member
    Posted 9 months ago #

    Suppose that I have one custom taxonomy (brands) and two custom post types ("cameras" and "lens") depending both on brands taxonomy.

    I want to display all cannon lens when put this url:
    http://mysite.com/lens/cannon/
    and all cannon cameras when i put this url:
    http://mysite.com/cameras/cannon/

    What this urls does now:
    They both show me cannon cameras and lens in the archive page, but i want them listed separately depending on the url.

    This is my rewrite argument in camera cpt registration:

    'rewrite' => array('slug' => 'cameras/%brand%', 'with_front' => TRUE),

    and lens cpt registration:

    'rewrite' => array('slug' => 'lens/%brand%', 'with_front' => TRUE),

    If anybody can help, i 'll appreciate.

  2. djvern
    Member
    Posted 7 months ago #

    This is exactly what I need to do - I need the following structure:

    http://mysite.com/events/area/london
    http://mysite.com/exhibitions/area/london

    where 'area' is a taxonomy and 'london' is one of its terms. How can I create urls of events/area and exhibitions/area from the same taxonomy? I figure I need to somehow pass a variable to the custom taxonomy rewrite slug to say that 'if post type that the user is on is 'events', then change the first part of the taxonomy slug to include the post type slug - eg '/%post_type%/area'. Is this possible?

    Obviously I could just duplicate the area taxonomy, and call one 'event-area' and the other 'exhibitions-area', but this seems horribly inefficient...

    Any help on this would be great, thanks!

Reply

You must log in to post.

About this Topic