0

I am using custom post types on a new site I am setting up as follows.

One Custom Post Type is STORES with multiple taxonomies (eg Location, Category, Brands, Payment Types etc) and also some custom fields (address, phone)

Other custom post types are DEALS also with taxonomies (brand, deal type, discount etc) which I was hoping to link to the STORES post type.

For example Store 1 has its own listing with all the information about that store. Then I create deal 1 which is a deal offered by Store 1.

Is this possible? What would be the best way to achieve this? In future I might also add reviews or products as a custom post type also linked by store.

Hope this makes sense!!!

Richard

1

You want Posts 2 Posts which allows you to create many to many (or one to many or many to one) relationships between post objects -- including custom post types.

To related stores and deals you might do something like this...

<?php
add_action('p2p_init', 'wpse102461_connection');
function wpse102461_connection()
{
    p2p_register_connection_type(array(
        'name' => 'stores_to_deals',
        'from' => 'STORES', // or whatever your custom post type actual is
        'to'   => 'DEALS', // or whatever your deals type is
    ));
}

This will create the admin interface (which you can customize) for you and provide a way to fetch associated deals.

Or you could overload post_parent to do what you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.