Advertisement
webrur

Class 8

Apr 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. function factorian_post_list( $atts, $content = null ){
  2.  
  3. extract(shortcode_atts(array(
  4. 'posttype' => '',
  5. 'count' => '',
  6.  
  7. ), $atts));
  8.  
  9. $q = new WP_Query(array(
  10. 'post_type' => array($posttype),
  11. 'posts_per_page' => $count,
  12. 'order' => '',
  13. 'orderby' => '',
  14. ));
  15.  
  16. $list = '<div class="custom_post_list"> ';
  17.  
  18. while($q->have_posts()) : $q->the_post();
  19. $idd = get_the_ID;
  20. $custom_field = get_post_meta($idd, 'custom_field', true);
  21. $post_content = get_the_content();
  22.  
  23. $list .= '<ul>';
  24. $list .= '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
  25. $list .= '</ul>';
  26.  
  27. endwhile;
  28.  
  29. $list .= '</div>';
  30.  
  31. return $list;
  32. }
  33. add_shortcode('post_list', 'factorian_post_list');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement