Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The easy solution would be to wrap all the echo statements inside a conditional which checks that the author meta value is yes before echoing out the content. With a lot of authors, this would get very inefficient, a separate SQL query for every author.

    A better solution would be to alter the get_results() query to only return authors that have the yes meta value in the first place. This involves joining in the usermeta table in order for the query to check for the correct values. While this is a somewhat straight forward query, I don’t know exactly how to write it without some research and trials of my own. Unless someone else here can contribute, you’re on your own with this one.

    An equivalent approach which may be easier to code (especially if you are familiar with WP_Query) would be to use a WP_User_Query to form and execute the query. It does include meta query capabilities. You end up with the same array of author/user objects, but you are spared mySQL syntax in favor of PHP and WP query syntax. Pick your poison 🙂

    The last one I could help you on if need be, except I will have sporadic Internet access for the next week or so. Response time could be a few days.

Viewing 1 replies (of 1 total)

The topic ‘Filter Function based on Author Meta Field Values’ is closed to new replies.