Advertisement
shakil97bd

Custom post shortcode query

Aug 18th, 2014
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. ************************Custom post shortcode query *********************
  2.  
  3.  
  4. //custom post shortcode query
  5.  
  6. function customer_services_shortcode($atts){
  7. extract( shortcode_atts( array(
  8. 'title' => '',
  9. 'dsc' => '',
  10. 'link' => '',
  11. 'category' => ''
  12. ), $atts, 'service' ) );
  13.  
  14. $q = new WP_Query(
  15. array('posts_per_page' => -1, 'post_type' => 'customer_services', 'services_cat' => $category)
  16. );
  17.  
  18.  
  19. $list = '
  20.  
  21.  
  22.  
  23. ';
  24. while($q->have_posts()) : $q->the_post();
  25. $idd = get_the_ID();
  26.  
  27. $service_icon = get_post_meta($idd, 'icon_service', true);
  28.  
  29. $list .= '
  30.  
  31.  
  32.  
  33. ';
  34. endwhile;
  35. $list.= '
  36.  
  37.  
  38.  
  39. ';
  40. wp_reset_query();
  41. return $list;
  42. }
  43. add_shortcode('service', 'customer_services_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement