Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. // Portfolio CPT
  2. function portfolio_cpt() {
  3. $labels = array(
  4. 'name' => _x( 'Potfolio Items', 'post type general name' ),
  5. 'singular_name' => _x( 'Portfolio item', 'post type singular name' ),
  6. 'menu_name' => 'Portfolio Items'
  7. );
  8. $args = array(
  9. 'labels' => $labels,
  10. 'description' => 'Portfolio items',
  11. 'public' => true,
  12. 'menu_position' => 5,
  13. 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
  14. 'has_archive' => true,
  15. );
  16. register_post_type( 'portfolio', $args );
  17. }
  18. add_action( 'init', 'portfolio_cpt' );
  19.  
  20. function portfolio_tax() {
  21. $labels = array(
  22. 'name' => _x( 'Portfolio Categories', 'taxonomy general name' ),
  23. 'singular_name' => _x( 'Portfolio Category', 'taxonomy singular name' ),
  24. 'menu_name' => __( 'Portfolio Categories' ),
  25. );
  26. $args = array(
  27. 'labels' => $labels,
  28. 'hierarchical' => true,
  29. );
  30. register_taxonomy( 'portfolio_category', 'portfolio', $args );
  31. }
  32. add_action( 'init', 'portfolio_tax', 0 );
  33.  
  34. <?php
  35.  
  36. $taxonomy = 'portfolio_category';
  37. $terms = get_terms($taxonomy);
  38.  
  39. if ( $terms && !is_wp_error( $terms ) ) :
  40. ?>
  41. <ul>
  42. <?php foreach ( $terms as $term ) { ?>
  43. <li><a href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; ?></a></li>
  44. <?php } ?>
  45. </ul>
  46. <?php endif;?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement