You can do this using WP_Query since 3.1 with a meta_query.
$args = array(
'meta_key' => '_count-views_all',
'orderby' => 'meta_value_num',
'order' => $sortOrder,
'posts_per_page' => 9,
'paged' => $paged,
'meta_query' => array(
'relation' => 'OR'
array(
'key' => 'contributorid1',
'value' => $id,
'compare' => '='
),
array(
'key' => 'contributorid2',
'value' => $id,
'compare' => '='
)
)
);
$query = new WP_Query( $args );
Related Posts:
- How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?
- query_posts doesn’t order by title
- get_post_meta causes database queries
- Using database meta_values to calculate new post order using pre_get_posts or a ‘request’ hook
- Display custom post types with custom date field value (before today) & order by custom date field
- Ordering terms before displaying posts
- Sort Posts by Multiple Meta Values [duplicate]
- ACF Custom Field WP_Query, but need to get all posts, if field doesn’t exist
- orderby:date not working
- WordPress query_posts and orderby page order
- Single meta key with multiple meta value in like comparison
- Order posts by condition
- order posts by meta value on posts page
- Change order of posts
- Sorting a query Field by date
- define orderby URL with meta_key=post_views_count
- WP Query – Is this correct?
- Filter Loop by Custom Field Value
- meta_query check for meta value in key which holds an array of values
- WordPress query reverse order
- Meta query stopped working
- Custom query looking at multiple custom fields and properly sorting
- Tax query get first product with attribute value in pre_get_posts
- Ordering Posts By Meta Data
- Order posts by ACF checkbox
- query_posts() with multiple meta data comparisons
- orderby not working for query_posts using array of IDs
- How to Get All Posts with any post status?
- posts_per_page no limit
- Nested meta_query with multiple relation keys
- How can i get count from query post
- query_post by title?
- Why query_posts() isn’t marked as deprecated?
- Alternative to query_posts for main loop? [duplicate]
- how to query posts by category and tag?
- Using WP_Query to Query Multiple Categories with Limited Posts Per Category?
- Using meta_query, how can i filter by a custom field and order by another one?
- Order by meta value or date?
- How do I query by post format in WordPress 3.1
- Display posts of the last 7 days
- Is there a way to exclude the content from the post variable to save on RAM usage?
- Filtering posts by post meta data
- ORDER BY custom field value
- Sorting: custom query with orderby meta_value_num THEN by title
- Query posts by custom taxonomy ID
- Fail to compare dates in meta_query
- Display/query post formats
- Order by & include array by specific post ids
- How to query post by user role?
- How to return results of a get_posts() in explicitly defined order
- Query Posts in a Predefined Order
- Help to condense/optimize some working code
- Order posts by ID in the given order
- Custom WP_Query order by post_meta and (author) user_meta
- How to set posts per page using WP_Query()
- query_posts exclude a meta key
- How do I create a random post that will last for a day
- Ensuring sticky posts are retrieved first (without using two queries)?
- Query Multiple Post types each with own meta query
- Determine if more posts are available than was asked for in `query_posts()`?
- Modify main WordPress loop with a parse_query filter
- Ordering posts having multiple post-meta date fields
- query_posts() in function makes global $wp_query out of sync?
- Limiting query_posts to 1, regardless of sticky post?
- How to make “sticky” pages (and query by them)
- Query posts: how to exclude results if post is in multiple categories
- query_posts ->using meta_compare / where meta value is smaller or greater or equals
- Problem with ‘post__not_in’
- How to order posts by descending comment count on taxonomy page?
- Sort posts alphabetically by custom field value, insert divider between different letters
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- WP 5.8 “Query Loop” block: where to place custom query?
- Order Posts by Taxonomy and Meta Value
- Perform query with meta_value date
- WP_Query ordered by custom field that is a date string?
- Sort X categories by last update and show image
- Custom Post Type “Event”: chronological list of recurring events
- Meta query interfering with orderby relevance
- Meta Query with date and time on the same Day before given time
- using post__in allow duplicate post id
- Pagination on archive.php page
- WP REST API: Order posts by meta value (acf)?
- Trying to perform complex custom field query with order by set to field value
- WordPress Custom Query
- Best way to load page content in Fancybox popup?
- search query within custom taxonomy term, post title and meta field
- How should I intercept the main query and inject custom join / order by / group by criteria
- Is there a way to do multiple ordering on a multiple meta_query?
- advice on creating a ‘related posts’ query like the one used on stackexchange
- order post my meta value m/d/y format with year as included value
- Order by meta value, pro first, then free
- Having trouble generating pagination links on custom query
- How to create an attachments archive with working pagination?
- _wp_page_template to dynamically use template
- order by meta_value serialized array
- How do I create my own nested meta_query using posts_where / posts_join?
- Using dynamic conditions in ‘posts_where’ filter
- Order by nested named meta queries with ‘exists’ and ‘not exists’
- Using Query Posts With Multiple Post Types And A Taxonomy
- Help altering a query to exclude all but standard post format