
Untitled
By: a guest on
Nov 10th, 2011 | syntax:
None | size: 1.22 KB | hits: 96 | expires: Never
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;
}
}