Guest User

Untitled

a guest
Mar 22nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. // prepare our arguments for the query
  2. $args = json_decode( stripslashes( $_POST['query'] ), true );
  3. $args['paged'] = $_POST['page'] + 1; // we need next page to be loaded
  4. $args['post_status'] = 'publish';
  5.  
  6. // it is always better to use WP_Query but not here
  7. query_posts( $args );
  8.  
  9. if( have_posts() ) :
  10.  
  11. // run the loop
  12. while( have_posts() ): the_post();
  13.  
  14. // look into your theme code how the posts are inserted, but you can use your own HTML of course
  15. // do you remember? - my example is adapted for Twenty Seventeen theme
  16. get_template_part( 'template-parts/post/content', get_post_format() );
  17. // for the test purposes comment the line above and uncomment the below one
  18. // the_title();
  19.  
  20.  
  21. endwhile;
  22.  
  23. endif;
  24. die; // here we exit the script and even no wp_reset_query() required!
Add Comment
Please, Sign In to add comment