Advertisement
Guest User

Untitled

a guest
Nov 10th, 2011
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. add_action('init', 'demo_register_post_type');
  2.  
  3. function demo_register_post_type() {
  4. register_post_type('tribe_events', array( 'rewrite' => array('slug' => 'event', 'with_front' => false),
  5. 'labels' => array(
  6. 'name' => 'Demos',
  7. 'singular_name' => 'Demo',
  8. 'add_new' => 'Add new demo',
  9. 'edit_item' => 'Edit demo',
  10. 'new_item' => 'New demo',
  11. 'view_item' => 'View demo',
  12. 'search_items' => 'Search demos',
  13. 'not_found' => 'No demos found',
  14. 'not_found_in_trash' => 'No demos found in Trash'
  15. ),
  16. 'public' => true,
  17. 'supports' => array(
  18. 'title',
  19. 'excerpt'
  20. ),
  21. 'taxonomies' => array('category', 'post_tag') // this is IMPORTANT
  22. ));
  23. }
  24.  
  25.  
  26. add_filter('pre_get_posts', 'query_post_type');
  27. function query_post_type($query) {
  28. if(is_archive() || is_tag() || is_home() && empty( $query->query_vars['suppress_filters'] ) ) {
  29. $post_type = get_query_var('post_type');
  30. if($post_type)
  31. $post_type = $post_type;
  32. else
  33. $post_type = array('post','tribe_events','attachment');
  34. $query->set('post_type',$post_type);
  35. return $query;
  36. }
  37. }
  38.  
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement