WordPress.org

Ready to get started?Download WordPress

Forums

CPT-onomies: Using Custom Post Types as Taxonomies
[resolved] Archive Page Slug problem (5 posts)

  1. toojee
    Member
    Posted 9 months ago #

    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/

  2. Rachel Carden
    Member
    Plugin Author

    Posted 9 months ago #

    I'd check out the documentation for Custom CPT-onomy Archive Pages. I think you'll find your answer there.

  3. toojee
    Member
    Posted 9 months ago #

    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?

  4. toojee
    Member
    Posted 9 months ago #

    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!

  5. Rachel Carden
    Member
    Plugin Author

    Posted 9 months ago #

    Awesome! Glad you figured it out!

Reply

You must log in to post.

About this Plugin

About this Topic