Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Functions.php
- add_action( 'init', 'downwards_create_taxonomies' );
- function downwards_create_taxonomies() {
- // portfolio taxonomies
- $cat_labels = array(
- 'name' => __( 'Portfolio Categories', '' ),
- 'singular_name' => __( 'Portfolio Category', '' ),
- 'search_items' => __( 'Search Portfolio Categories', '' ),
- 'all_items' => __( 'All Portfolio Categories', '' ),
- 'parent_item' => __( 'Parent Portfolio Category', '' ),
- 'parent_item_colon' => __( 'Parent Portfolio Category:', '' ),
- 'edit_item' => __( 'Edit Portfolio Category', '' ),
- 'update_item' => __( 'Update Portfolio Category', '' ),
- 'add_new_item' => __( 'Add New Portfolio Category', '' ),
- 'new_item_name' => __( 'New Portfolio Category Name', '' ),
- 'choose_from_most_used' => __( 'Choose from the most used portfolio categories', '' )
- );
- register_taxonomy('portfolio-category','portfolio',array(
- 'hierarchical' => true,
- 'labels' => $cat_labels,
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'portfolio-category' ),
- ));
- }
- //Calling Taxonomy In Theme
- <?php
- $cats = get_terms('portfolio-category');
- if($cats[0]) { ?>
- <div id="filter">
- <li><a href="#" class="active" data-filter="*"><span><?php _e('All', 'downwards') . '/'; ?></span></a></li>
- <?php
- foreach ($cats as $cat ) : ?>
- <li><a href="#" data-filter=".<?php echo $cat->slug; ?>"><span><?php echo '/ ' . $cat->name; ?></span></a></li>
- <?php endforeach; ?>
- </div>
- <?php } ?>
- <div id="p_container_2">
- <?php query_posts(array( 'post_type' => 'portfolio' )); ?>
- <?php while (have_posts()) : the_post(); $terms = get_the_terms( get_the_ID(), 'portfolio-category' ); ?>
- <div class="p_brick_2 <?php if($terms) foreach ($terms as $term) echo $term->slug .' '; ?>">
- <a href="<?php the_permalink(); ?>"><?php if ( has_post_thumbnail()) : the_post_thumbnail('port-post-2'); endif; ?></a>
- <div class="p_brick_2_c">
- <h2><?php the_title(); ?></h2>
- <p><?php echo get_the_term_list( $post->ID, 'portfolio-category', '', ' / ', '', '' ); ?></p>
- </div>
- </div>
- <?php endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement