ajayver

Untitled

Jul 10th, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.63 KB | None | 0 0
  1. function create_post_types() {
  2.         global $smof_data;
  3.         // Portfolio post type
  4.         register_post_type( 'us_portfolio',
  5.             array(
  6.                 'labels' => array(
  7.                     'name' => 'Portfolio Items',
  8.                     'singular_name' => 'Portfolio Item',
  9.                     'add_new' => 'Add Portfolio Item',
  10.                 ),
  11.                 'public' => true,
  12. //                'has_archive' => true,
  13.                 'rewrite' => array('slug' => $smof_data['portfolio_slug']),
  14.                 'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'comments'),
  15.                 'can_export' => true,
  16.             )
  17.         );
  18.  
  19.         // Clients post type
  20.         register_post_type( 'us_client',
  21.             array(
  22.                 'labels' => array(
  23.                     'name' => 'Clients Logos',
  24.                     'singular_name' => 'Client Logo',
  25.                     'add_new' => 'Add Client Logo',
  26.                 ),
  27.                 'public' => true,
  28.                 'publicly_queryable' => false,
  29. //                'has_archive' => true,
  30.                 'supports' => array('title', 'thumbnail'),
  31.                 'can_export' => true,
  32.             )
  33.         );
  34.  
  35.  
  36.  
  37.     }
  38.  
  39.     // Portfolio categories
  40.     register_taxonomy('us_portfolio_category', array('us_portfolio'), array('hierarchical' => true, 'label' => 'Portfolio Categories','singular_label' => 'Portfolio Category', 'rewrite' => true));
  41.  
  42.     function portfolio_add_taxonomy_filters() {
  43.         global $typenow;
  44.  
  45.         // An array of all the taxonomyies you want to display. Use the taxonomy name or slug
  46.         $taxonomies = array( 'us_portfolio_category' );
  47.  
  48.         // must set this to the post type you want the filter(s) displayed on
  49.         if ( $typenow == 'portfolio' ) {
  50.  
  51.             foreach ( $taxonomies as $tax_slug ) {
  52.                 $current_tax_slug = isset( $_GET[$tax_slug] ) ? $_GET[$tax_slug] : false;
  53.                 $tax_obj = get_taxonomy( $tax_slug );
  54.                 $tax_name = $tax_obj->labels->name;
  55.                 $terms = get_terms($tax_slug);
  56.                 if ( count( $terms ) > 0) {
  57.                     echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";
  58.                     echo "<option value=''>$tax_name</option>";
  59.                     foreach ( $terms as $term ) {
  60.                         echo '<option value=' . $term->slug, $current_tax_slug == $term->slug ? ' selected="selected"' : '','>' . $term->name .' (' . $term->count .')</option>';
  61.                     }
  62.                     echo "</select>";
  63.                 }
  64.             }
  65.         }
  66.     }
Advertisement
Add Comment
Please, Sign In to add comment