Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('init', 'demo_register_post_type');
- function demo_register_post_type() {
- register_post_type('tribe_events', array( 'rewrite' => array('slug' => 'event', 'with_front' => false),
- 'labels' => array(
- 'name' => 'Demos',
- 'singular_name' => 'Demo',
- 'add_new' => 'Add new demo',
- 'edit_item' => 'Edit demo',
- 'new_item' => 'New demo',
- 'view_item' => 'View demo',
- 'search_items' => 'Search demos',
- 'not_found' => 'No demos found',
- 'not_found_in_trash' => 'No demos found in Trash'
- ),
- 'public' => true,
- 'supports' => array(
- 'title',
- 'excerpt'
- ),
- 'taxonomies' => array('category', 'post_tag') // this is IMPORTANT
- ));
- }
- add_filter('pre_get_posts', 'query_post_type');
- function query_post_type($query) {
- if(is_archive() || is_tag() || is_home() && empty( $query->query_vars['suppress_filters'] ) ) {
- $post_type = get_query_var('post_type');
- if($post_type)
- $post_type = $post_type;
- else
- $post_type = array('post','tribe_events','attachment');
- $query->set('post_type',$post_type);
- return $query;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement