Support » Plugin: CPT-onomies: Using Custom Post Types as Taxonomies » Archive Page Slug problem

  • Resolved toojee

    (@toojee)


    Hi!

    I have trouble to understand how CTP-onomies works with archive page.
    I have a CPT “hotel” and another CPT “city”.
    In CPT-onomies city I have checked the “Attach to Post Types” hotel to get city at the right of admin post hotel. That works and that ok.

    But for the Archive Page Slug for all hotel in a city I want “www.domain.com/hotel/city/new-york” for example. But in city cpt archive slug i have “www.domain.com/city/tax/new-york”.

    It is possible to that with this plugin?
    Because the $post_type refer to city and not to hotel… In fact I will use city with another CPT later like house for example. I will need with same CPT city “www.domain.com/house/city/new-york” to show just the house in new york.

    thanks

    http://wordpress.org/plugins/cpt-onomies/

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’d check out the documentation for Custom CPT-onomy Archive Pages. I think you’ll find your answer there.

    Thread Starter toojee

    (@toojee)

    Thanks for the answer!

    I wrote this rule in functions.php :
    add_rewrite_rule( "^hotel/city/([^/]*)/?", "index.php?post_type=hotel&city=$matches[1]&cpt_onomy_archive=1", "top" );

    When i go in url like “www.domain.com/hotel/city/new-york/” I have a archive page but not whith the hotels in new york city. I have listed all the hotels in all cities. In the sql query I don’t see city involve.

    “city” is of course a post type attach to post type “hotel”.
    I need to do something more to make this working?

    Thread Starter toojee

    (@toojee)

    Ok sorry I find my problem!
    With help of Rewrite Rules Inspector plugin I see I use double quotes intead of simple quote in add_rewrite_rule, so php convert $matches[1] to nothing.

    This works perfectly!

    Awesome! Glad you figured it out!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Archive Page Slug problem’ is closed to new replies.