| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
- /*------------------------------------------------------*/
- /* taskereasy Heading
- /*------------------------------------------------------*/
- vc_map(array(
- "name" => esc_html__("Portfolio Posts", 'taskereasy'),
- "base" => "taskereasy_portfolios_post",
- 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
- "class" => "",
- "description" => esc_html__("Add taskereasy portfolios post type", 'taskereasy'),
- "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
- "params" => array(
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Post Columns", 'taskereasy'),
- "param_name" => "post_coloumns",
- "value" => array('Two with big column' => '3', 'Three with big column' => '4'),
- ),
- array(
- 'type' => 'css_editor',
- 'heading' => esc_html__( 'CSS', 'taskereasy' ),
- 'param_name' => 'custom_design',
- 'group' => esc_html__( 'Design options', 'taskereasy' ),
- )
- )
- ));
- add_shortcode( 'taskereasy_portfolios_post', function($atts, $content = null) {
- extract(shortcode_atts(array(
- 'blog_post' => '',
- 'post_coloumns' => '3',
- 'post_style' => 'grid',
- 'custom_design' => '',
- ), $atts));
- $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
- $postcoloumns = html_entity_decode(vc_value_from_safe($post_coloumns, true));
- $output = '';
- $output .= '<div class="portfolio-list">';
- $col_num = ($postcoloumns == '3')? '6' : '4';
- $args = array(
- 'post_type' => 'portfolios',
- 'orderby' => 'date',
- 'posts_per_page' => $postcoloumns-1,
- 'offset' => 0,
- );
- $the_query = new WP_Query( $args );
- $output .= '<div class="row">';
- if ( $the_query->have_posts() ) :
- global $post;
- while ( $the_query->have_posts() ) : $the_query->the_post();
- $output .='
- <div class="col-lg-'.$col_num.'">
- <div class="portfolio-box">';
- if(has_post_thumbnail()){
- $output .= '<div class="porfolio-img"> '.get_the_post_thumbnail().' </div>';
- }
- $output .= '<div class="portfolio-heading">';
- $term_list = wp_get_post_terms($post->ID, 'portfoliocategories', array("fields" => "all"));
- //$output .= print_r($term_list);
- $count = count($term_list);
- foreach($term_list as $term){
- $output .= ' <div class="portfolio-caty"><a href="'.get_term_link($term->slug, "portfoliocategories").'" >'.$term->name.'</a></div> ';
- }
- $output .= '<h3><a href="'.get_the_permalink().'">'.get_the_title().'</a></h3></div>
- </div>
- </div>';
- endwhile;
- wp_reset_postdata();
- else :
- $output .= '<p>'.esc_html__( 'Sorry, no posts matched your criteria.', 'taskereasy' ) .'</p>';
- endif;
- $output .= '</div>';
- //full portfolio
- $full_args = array(
- 'post_type' => 'portfolios',
- 'posts_per_page' => 1,
- 'orderby' => 'date',
- 'offset' => $postcoloumns-1,
- );
- $the_query = new WP_Query( $full_args );
- if ( $the_query->have_posts() ) {
- global $post;
- $output .= '<div class="full-portfolio">
- <div class="row">';
- while ( $the_query->have_posts() ) { $the_query->the_post();
- $output .= '<div class="col-lg-8">';
- if(has_post_thumbnail()){
- $output .= '<div class="porfolio-img"> '.get_the_post_thumbnail().' </div>';
- }
- $output .= '</div>
- <div class="col-lg-4">
- <div class="portfolio-col">';
- $term_list = wp_get_post_terms($post->ID, 'portfoliocategories', array("fields" => "all"));
- //$output .= print_r($term_list);
- $count = count($term_list);
- foreach($term_list as $term){
- $output .= ' <div class="portfolio-caty"><a href="'.get_term_link($term->slug, "portfoliocategories").'" >'.$term->name.'</a></div> ';
- }
- $output .= '<h3><a href="'.get_the_permalink().'">'.get_the_title().'</a></h3>
- <p>'.taskereasy_custom_excerpt_length(20).'</p>
- <a href="'.get_the_permalink().'" class="btn btn-md">'.esc_html__('Read More', 'taskereasy').'</a> </div>
- </div>';
- } //end while
- wp_reset_postdata();
- $output .= '</div>
- </div>';
- } // end if posts
- else {
- $output .= '<p>'.esc_html__( 'Sorry, no posts matched your criteria.', 'taskereasy' ) .'</p>';
- }
- $output .= '</div>';
- return $output;
- });
|