Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <section class="products-list">
  2. <?php
  3.  
  4. $current_page = get_queried_object();
  5. $category = $current_page->post_name;
  6.  
  7. $args = array( 'post_type' => 'product_elm', 'category_name' => $category, 'posts_per_page' => 2);
  8. $the_query = new WP_Query( $args );
  9.  
  10. if ( $the_query->have_posts() ) {
  11. while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
  12. <div class="item">
  13. <a href="<?php the_permalink() ?>">
  14. <div class="img">
  15. <?php the_post_thumbnail(); ?>
  16. </div>
  17. <h2> <?php the_title(); ?></h2>
  18. </a>
  19. </div>
  20.  
  21. <?php
  22. endwhile;
  23.  
  24. }
  25. next_posts_link( 'Older Entries', $the_query->max_num_pages );
  26. previous_posts_link( 'Newer Entries' );
  27. wp_reset_postdata();
  28. ?>
  29. </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement