Guest User

Untitled

a guest
May 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. $args = array(
  2. 'post_type' => array('post'),
  3. 'order' => 'DESC',
  4. 'category_name' => 'test',
  5. );
  6.  
  7. // The Query
  8. $query = new WP_Query( $args );
  9.  
  10. // The Loop
  11. if ( $query->have_posts() ) {
  12. while ( $query->have_posts() ) {
  13. $query->the_post();
  14. // Your custom code
  15. }
  16. } else {
  17. // no posts found
  18. }
  19. /* Restore original Post Data */
  20. wp_reset_postdata();
  21.  
  22. <?php
  23. global $post;
  24. $args = array( 'numberposts' => 10, 'category_name' => 'cat-slug' );
  25. $posts = get_posts( $args );
  26. foreach( $posts as $post ){
  27. setup_postdata($post);
  28. get_the_title();
  29. get_the_excerpt();
  30. get_the_content();
  31. }
  32. ?>
  33.  
  34. $wp_argu = array(
  35. 'post_type' => 'prayer',
  36. 'posts_per_page' => '-1',
  37. 'suppress_filters' => false,
  38. 'tax_query' => array(
  39. array(
  40. 'taxonomy' => 'category',
  41. 'field' => 'slug', // id, name
  42. 'terms' => 'bob',
  43. ),
  44. ),
  45. );
  46.  
  47. $query = new WP_Query( $wp_argu );
Add Comment
Please, Sign In to add comment