0

I've looked around but can't find a decent solution.

I have a custom post type that adds businesses. In the loop it will list all by default but I want to be able to attach an event category to each custom post so I can filter on separate pages by that event.

Basically each custom post will have a category assigned. So event 'PartyOne' will have custom post with details, a FAQ, Sponsor list.

I have custom posts for sponsor list and FAQ but is there a way to group them all together? So when they hit the PartyOne page, it links the FAQ, Sponsors and the post content for that event?

I thought of registering the custom post type then assinging the url with the category so mysite.com/partyone/exhibiting/businessname but when I make the custom post it only writes mysite.com/exhibiting/businessname where I need 'partyone' as a cat to bind them all together here is what I have so far

// Register custom taxonomy before post type
function add_event_taxonomies() {

        register_taxonomy('event', 'exhibitors', array(
                // Hierarchical taxonomy (like categories)
                'hierarchical' => true,
                // This array of options controls the labels displayed in the WordPress Admin UI
                'labels' => array(
                        'name' => _x( 'Exhibitor Category', 'taxonomy general name' ),
                        'singular_name' => _x( 'Exhibitor-Category', 'taxonomy singular name' ),
                        'search_items' =>  __( 'Search Exhibitor-Categories' ),
                        'all_items' => __( 'All Exhibitor-Categories' ),
                        'parent_item' => __( 'Parent Exhibitor-Category' ),
                        'parent_item_colon' => __( 'Parent Exhibitor-Category:' ),
                        'edit_item' => __( 'Edit Exhibitor-Category' ),
                        'update_item' => __( 'Update Exhibitor-Category' ),
                        'add_new_item' => __( 'Add New Exhibitor-Category' ),
                        'new_item_name' => __( 'New Exhibitor-Category Name' ),
                        'menu_name' => __( 'Exhibitor Categories' ),
                ),
                // Control the slugs used for this taxonomy
                'rewrite' => array(
                        'slug' => 'exhibitors/%category%', // This controls the base slug that will display before each term
                        'with_front' => false, // Don't display the category base before "/locations/"
                        'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
                ),
        ));
}
add_action( 'init', 'add_event_taxonomies', 0 );

// Register Exhibitors Post Type 
function exhibitors_init() {
    $args = array(
      'label' => 'Exhibitors',
        'public' => true,
        'show_ui' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'rewrite' => array('slug' => 'exhibitors'),
        'query_var' => true,
        'menu_icon' => 'dashicons-megaphone',
        'supports' => array(
            'title',
            'editor',
            'custom-fields',
            'revisions',
            'thumbnail',
            'page-attributes'),

        );
    register_post_type( 'exhibitors', $args );

}
add_action( 'init', 'exhibitors_init' );

So it registers a custom category for Exhibitors but when I create a new post it wont attach the category to the permalink. Any ideas? Also if there is a better solution I am open to starting over

0

WordPress Types have that features. So, you don't need to code by yourself or use custom post type generator. I hope you would get answer in there. Sorry for quick answers without modification your codes :)

| improve this answer | |

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.