Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Portfolio CPT
- function portfolio_cpt() {
- $labels = array(
- 'name' => _x( 'Potfolio Items', 'post type general name' ),
- 'singular_name' => _x( 'Portfolio item', 'post type singular name' ),
- 'menu_name' => 'Portfolio Items'
- );
- $args = array(
- 'labels' => $labels,
- 'description' => 'Portfolio items',
- 'public' => true,
- 'menu_position' => 5,
- 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
- 'has_archive' => true,
- );
- register_post_type( 'portfolio', $args );
- }
- add_action( 'init', 'portfolio_cpt' );
- function portfolio_tax() {
- $labels = array(
- 'name' => _x( 'Portfolio Categories', 'taxonomy general name' ),
- 'singular_name' => _x( 'Portfolio Category', 'taxonomy singular name' ),
- 'menu_name' => __( 'Portfolio Categories' ),
- );
- $args = array(
- 'labels' => $labels,
- 'hierarchical' => true,
- );
- register_taxonomy( 'portfolio_category', 'portfolio', $args );
- }
- add_action( 'init', 'portfolio_tax', 0 );
- <?php
- $taxonomy = 'portfolio_category';
- $terms = get_terms($taxonomy);
- if ( $terms && !is_wp_error( $terms ) ) :
- ?>
- <ul>
- <?php foreach ( $terms as $term ) { ?>
- <li><a href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; ?></a></li>
- <?php } ?>
- </ul>
- <?php endif;?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement