Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. //functions.php
  2. function search_distinct() {
  3. return "DISTINCT";
  4. }
  5. add_filter('posts_distinct', 'search_distinct');
  6.  
  7. //archive.php
  8. <?php
  9. $args = array(
  10. 'post_type' => 'homily',
  11. 'posts_per_page' => -1,
  12. 'meta_key' => 'homilist',
  13. 'orderby' => 'meta_value',
  14. 'order' => 'ASC'
  15. );
  16. $the_query = new WP_Query( $args );
  17.  
  18. search_distinct(); //Correct?
  19.  
  20. if ( $the_query->have_posts() ) {
  21. echo '<ul>';
  22. while ( $the_query->have_posts() ) {
  23. $the_query->the_post();
  24. echo '<li>' .the_field('homilist') . '</li>';
  25. }
  26. echo '</ul>';
  27. }
  28. wp_reset_postdata(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement