Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //functions.php
- function search_distinct() {
- return "DISTINCT";
- }
- add_filter('posts_distinct', 'search_distinct');
- //archive.php
- <?php
- $args = array(
- 'post_type' => 'homily',
- 'posts_per_page' => -1,
- 'meta_key' => 'homilist',
- 'orderby' => 'meta_value',
- 'order' => 'ASC'
- );
- $the_query = new WP_Query( $args );
- search_distinct(); //Correct?
- if ( $the_query->have_posts() ) {
- echo '<ul>';
- while ( $the_query->have_posts() ) {
- $the_query->the_post();
- echo '<li>' .the_field('homilist') . '</li>';
- }
- echo '</ul>';
- }
- wp_reset_postdata(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement