Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function styler_theme_features() {
- // Add theme support for Featured Images
- add_theme_support( 'post-thumbnails', array( 'portfolio' ) ); //post, page, and other custom post type can be added, up to you
- add_image_size( 'portfolio-thumb', 300, 300, true );
- }
- // Hook into the 'after_setup_theme' action
- add_action( 'after_setup_theme', 'styler_theme_features' );
- //add "type" taxonomy slug to post class
- function styler_portfolio_class( $classes ) {
- global $post;
- $terms = get_the_terms( $post->ID, 'type' );
- if( 'portfolio' === $post->post_type ) {
- unset($classes);
- $classes[] = 'mix';
- foreach ( $terms as $term ) {
- $classes[] = $term->slug;
- }
- return $classes;
- }
- return $classes;
- }
- // Custom query to fetch portfolio items
- <div class="portfolio-wrap">
- <ul class="portfolio-filter">
- <?php $terms = get_terms('type', 'hide_empty=0');
- echo '<li class="filter" data-filter="all">All</li>';
- foreach( $terms as $term ) {
- echo '<li class="filter" data-filter=".' . $term->slug . '">' . $term->name . '</li>';
- }
- ?>
- </ul><!-- /.portfolio-filter -->
- <ul id="portfolio">
- <?php
- query_posts('post_type=portfolio&post_per_page=-1');
- if( have_posts() ):
- while( have_posts() ): the_post();
- ?>
- <li <?php post_class(); ?>>
- <figure>
- <?php if( has_post_thumbnail() ): ?>
- <?php the_post_thumbnail( 'portfolio-thumb' ) ?>
- <?php endif; ?>
- <figcaption>
- <h2>
- <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
- </h2>
- </figcaption>
- </figure>
- </li>
- <?php
- endwhile;
- endif;
- wp_reset_query();
- ?>
- </ul><!-- /#portfolio -->
- </div><!-- /.portfolio-wrap -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement