| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- /*------------------------------------------------------*/
- /* taskereasy Heading
- /*------------------------------------------------------*/
- vc_map(array(
- "name" => esc_html__("Service Posts", 'taskereasy'),
- "base" => "taskereasy_services_post",
- 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
- "class" => "",
- "description" => esc_html__("Add taskereasy services 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('Three columns' => '3', 'Four Column' => '4'),
- ),
- array(
- 'type' => 'css_editor',
- 'heading' => esc_html__( 'CSS', 'taskereasy' ),
- 'param_name' => 'custom_design',
- 'group' => esc_html__( 'Design options', 'taskereasy' ),
- )
- )
- ));
- add_shortcode( 'taskereasy_services_post', function($atts, $content = null) {
- extract(shortcode_atts(array(
- 'post_coloumns' => '3',
- 'custom_design' => '',
- ), $atts));
- $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
- $postcoloumns = html_entity_decode(vc_value_from_safe($post_coloumns, true));
- $output = '';
- $args = array(
- 'post_type' => 'services',
- 'orderby' => 'date',
- 'posts_per_page' => -1,
- );
- $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();
- $col_num = ($postcoloumns == 4)? '3' : '4';
- $output .='
- <div class="col-lg-'.$col_num.' col-md-6">
- <div class="service-wrap">
- <div class="service-image">';
- if(has_post_thumbnail()){
- $output .= '<a href="'.get_the_permalink().'">'.get_the_post_thumbnail().'</a>';
- }
- $output .= '</div>
- <h5><a href="'.get_the_permalink().'">'.get_the_title().'</a></h5>
- <p>'.taskereasy_custom_excerpt_length(20).'</p>
- <a href="'.get_the_permalink().'" class="btn-link">'.esc_html__('More info', 'taskereasy') .' <i class="fa fa-angle-right"></i></a>
- </div>
- </div>';
- endwhile;
- wp_reset_postdata();
- else :
- $output .= '<p>'.esc_html__( 'Sorry, no posts matched your criteria.', 'taskereasy' ) .'</p>';
- endif;
- $output .= '</div>';
- return $output;
- });
|