Advertisement
arnabkumar

post_quary_in_shortcode

Jul 4th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2. //post_quary in shortcode
  3.  
  4.  
  5. function department_shortcod($atts){
  6. extract( shortcode_atts( array(
  7. 'category' => '',
  8. ), $atts, 'department' ) );
  9.  
  10.  
  11.     $q = new WP_Query(
  12.         array('posts_per_page' => '6','post_type' => 'department',/* Here use post-type*/
  13.              'department_cat' => $category,)
  14.         );
  15.        
  16.        
  17.     $list = 'Here use container start div of your post';/* Here use befour div of your post */
  18.    
  19.     while($q->have_posts()) : $q->the_post();
  20.     $idd = get_the_ID();
  21.  
  22.     $list .= 'Here use your code for post';/* Here use your code for post */        
  23.     endwhile;
  24.     $list.= 'Here use container end div of your post
  25.     ';
  26.     wp_reset_query();
  27.     return $list;
  28.     }
  29.  
  30.  
  31. add_shortcode('deparment', 'department_shortcod');
  32.  
  33.  
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement