I am currently trying to perform a custom query on the authors page (author.php). I have two custom fields for posts that I want to query against (post_photographer and post_videographer).
What I am trying to do for the author's profile is get all the posts for the current user profile where the user is:
- the author of the post
- OR the post photographer
- OR the post videographer
So each person's profile MAY have posts that they didn't author (they were the photographer or videographer instead).
The following code is close to what I want, but the problem is that it retrieves posts where the current user is the author AND is either a post photographer OR post videographer. It needs to be where the current user is the author OR post photographer OR post videographer.
$args = array( 'author' => $posts->post_author, 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'post_photographer', 'value' => $posts->post_author, 'type' => 'numeric' ), array( 'key' => 'post_videographer', 'value' => $posts->post_author, 'type' => 'numeric' ) ) ); query_posts( $args );
Is this possible via WordPress queries (query_posts or WP_Query), or do I need to write custom SQL? Any help is greatly appreciated! If you need clarification please ask.