WordPress.org

Ready to get started?Download WordPress

Forums

Exclude authors using 'post_author' query (3 posts)

  1. KeenanPayne
    Member
    Posted 2 years ago #

    Hey everybody. I have a template that I made show all of the authors on my site, unfortunately, I only want to show the current authors that write for the site (22 people) not every single person that has ever written an article (50+ people).

    Below is the query I'm using in my template and was wondering if there was any way I could exclude these authors that I don't want to show.

    <?php
                $authors = $wpdb->get_results('SELECT DISTINCT post_author FROM '.$wpdb->posts.' INNER JOIN '.$wpdb->users.' ON '.$wpdb->posts.'.post_author = '.$wpdb->users.'.ID ORDER BY '.$wpdb->users.'.display_name ASC');
                if($authors):
                foreach($authors as $author):
                ?>

    Thanks in advance for any help that you guys have, I very much appreciate it.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Why are you creating your own MySQL query and not using WP_Query?

  3. KeenanPayne
    Member
    Posted 2 years ago #

    This was in a premium template that I am using. I know WP_Query is preferred, but is there a way I can use that and accomplish what I'm trying to do?

Topic Closed

This topic has been closed to new replies.

About this Topic