Advertisement
Guest User

Untitled

a guest
May 7th, 2013
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. //Functions.php
  2. add_action( 'init', 'downwards_create_taxonomies' );
  3. function downwards_create_taxonomies() {
  4. // portfolio taxonomies
  5. $cat_labels = array(
  6. 'name' => __( 'Portfolio Categories', '' ),
  7. 'singular_name' => __( 'Portfolio Category', '' ),
  8. 'search_items' => __( 'Search Portfolio Categories', '' ),
  9. 'all_items' => __( 'All Portfolio Categories', '' ),
  10. 'parent_item' => __( 'Parent Portfolio Category', '' ),
  11. 'parent_item_colon' => __( 'Parent Portfolio Category:', '' ),
  12. 'edit_item' => __( 'Edit Portfolio Category', '' ),
  13. 'update_item' => __( 'Update Portfolio Category', '' ),
  14. 'add_new_item' => __( 'Add New Portfolio Category', '' ),
  15. 'new_item_name' => __( 'New Portfolio Category Name', '' ),
  16. 'choose_from_most_used' => __( 'Choose from the most used portfolio categories', '' )
  17. );
  18.  
  19. register_taxonomy('portfolio-category','portfolio',array(
  20. 'hierarchical' => true,
  21. 'labels' => $cat_labels,
  22. 'query_var' => true,
  23. 'rewrite' => array( 'slug' => 'portfolio-category' ),
  24. ));
  25. }
  26.  
  27. //Calling Taxonomy In Theme
  28. <?php
  29. $cats = get_terms('portfolio-category');
  30. if($cats[0]) { ?>
  31. <div id="filter">
  32. <li><a href="#" class="active" data-filter="*"><span><?php _e('All', 'downwards') . '/'; ?></span></a></li>
  33. <?php
  34. foreach ($cats as $cat ) : ?>
  35. <li><a href="#" data-filter=".<?php echo $cat->slug; ?>"><span><?php echo '/ ' . $cat->name; ?></span></a></li>
  36. <?php endforeach; ?>
  37. </div>
  38. <?php } ?>
  39.  
  40. <div id="p_container_2">
  41. <?php query_posts(array( 'post_type' => 'portfolio' )); ?>
  42. <?php while (have_posts()) : the_post(); $terms = get_the_terms( get_the_ID(), 'portfolio-category' ); ?>
  43. <div class="p_brick_2 <?php if($terms) foreach ($terms as $term) echo $term->slug .' '; ?>">
  44. <a href="<?php the_permalink(); ?>"><?php if ( has_post_thumbnail()) : the_post_thumbnail('port-post-2'); endif; ?></a>
  45. <div class="p_brick_2_c">
  46. <h2><?php the_title(); ?></h2>
  47. <p><?php echo get_the_term_list( $post->ID, 'portfolio-category', '', ' / ', '', '' ); ?></p>
  48. </div>
  49.  
  50. </div>
  51. <?php endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement