vc-services-blog.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Heading
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("Service Posts", 'taskereasy'),
  7. "base" => "taskereasy_services_post",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy services post type", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "dropdown",
  15. "heading" => esc_html__("Post Columns", 'taskereasy'),
  16. "param_name" => "post_coloumns",
  17. "value" => array('Three columns' => '3', 'Four Column' => '4'),
  18. ),
  19. array(
  20. 'type' => 'css_editor',
  21. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  22. 'param_name' => 'custom_design',
  23. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  24. )
  25. )
  26. ));
  27. add_shortcode( 'taskereasy_services_post', function($atts, $content = null) {
  28. extract(shortcode_atts(array(
  29. 'post_coloumns' => '3',
  30. 'custom_design' => '',
  31. ), $atts));
  32. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  33. $postcoloumns = html_entity_decode(vc_value_from_safe($post_coloumns, true));
  34. $output = '';
  35. $args = array(
  36. 'post_type' => 'services',
  37. 'orderby' => 'date',
  38. 'posts_per_page' => -1,
  39. );
  40. $the_query = new WP_Query( $args );
  41. $output .= '<div class="row">';
  42. if ( $the_query->have_posts() ) :
  43. global $post;
  44. while ( $the_query->have_posts() ) : $the_query->the_post();
  45. $col_num = ($postcoloumns == 4)? '3' : '4';
  46. $output .='
  47. <div class="col-lg-'.$col_num.' col-md-6">
  48. <div class="service-wrap">
  49. <div class="service-image">';
  50. if(has_post_thumbnail()){
  51. $output .= '<a href="'.get_the_permalink().'">'.get_the_post_thumbnail().'</a>';
  52. }
  53. $output .= '</div>
  54. <h5><a href="'.get_the_permalink().'">'.get_the_title().'</a></h5>
  55. <p>'.taskereasy_custom_excerpt_length(20).'</p>
  56. <a href="'.get_the_permalink().'" class="btn-link">'.esc_html__('More info', 'taskereasy') .' <i class="fa fa-angle-right"></i></a>
  57. </div>
  58. </div>';
  59. endwhile;
  60. wp_reset_postdata();
  61. else :
  62. $output .= '<p>'.esc_html__( 'Sorry, no posts matched your criteria.', 'taskereasy' ) .'</p>';
  63. endif;
  64. $output .= '</div>';
  65. return $output;
  66. });