Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Dynamic Portfolio With Shortcode
- function portfolio_shortcode($atts){
- extract( shortcode_atts( array(
- 'category' => ''
- ), $atts, '' ) );
- global $post;
- $q = new WP_Query(
- array('posts_per_page' => '-1', 'post_type' => 'portfolio')
- );
- //Portfolio taxanomy query
- $args = array(
- 'post_type' => 'portfolio',
- 'paged' => $paged,
- 'posts_per_page' => $data['portfolio_items'],
- );
- $portfolio = new WP_Query($args);
- if(is_array($portfolio->posts) && !empty($portfolio->posts)) {
- foreach($portfolio->posts as $gallery_post) {
- $post_taxs = wp_get_post_terms($gallery_post->ID, 'portfolio_category', array("fields" => "all"));
- if(is_array($post_taxs) && !empty($post_taxs)) {
- foreach($post_taxs as $post_tax) {
- $portfolio_taxs[$post_tax->slug] = $post_tax->name;
- }
- }
- }
- }
- if(is_array($portfolio_taxs) && !empty($portfolio_taxs) && get_post_meta($post->ID, 'pyre_portfolio_filters', true) != 'no'):
- ?>
- <!--Category Filter-->
- <div class="portfolio_menu">
- <ul>
- <?php foreach($portfolio_taxs as $portfolio_tax_slug => $portfolio_tax_name): ?>
- <li class="filter" data-filter=".<?php echo $portfolio_tax_slug; ?>"><?php echo $portfolio_tax_name; ?></li>
- <?php endforeach; ?>
- </ul>
- </div>
- <!--End-->
- <?php endif; ?>
- <?php
- $list = '<div class="portfolio_content"><ul id="Container"> <!-- mixitup -->';
- while($q->have_posts()) : $q->the_post();
- $idd = get_the_ID();
- //$portfolio_subtitle = get_post_meta($idd, 'portfolio_subtitle', true);
- //$filterr = get_post_meta($idd, 'filterr', true);
- //$small_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio_small_image' );
- //$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio_large_image' );
- //$small_image_url = the_post_thumbnail('project_smal_image', array('class' => 'post-thumb'));
- $post_thumbnail= get_the_post_thumbnail( $post->ID, 'portfolio_small_image' );
- //Get Texanmy class
- $item_classes = '';
- $item_cats = get_the_terms($post->ID, 'portfolio_category');
- if($item_cats):
- foreach($item_cats as $item_cat) {
- $item_classes .= $item_cat->slug . ' ';
- }
- endif;
- $single_link =
- $list .= '
- <li class="mix '.$item_classes.'">
- <div class="single_portfolio">
- <div class="single_portfolio_one">
- <div class="image">
- '.$post_thumbnail.'
- </div>
- <div class="overlay">
- <span><a href="'.get_the_permalink().'"><i class="fa fa-link"></i></a></span>
- </div>
- </div>
- </div>
- </li>
- ';
- endwhile;
- $list.= '</ul></div>';
- wp_reset_query();
- return $list;
- }
- add_shortcode('portfolio', 'portfolio_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement