All Questions
209
questions
0
votes
1
answer
28
views
Orderby meta _value that is saved as an array
I want to order a WP_User_Query by a meta value. The meta key is a multi-select field, and the value is saved as an array.
When I do a print_r of get_user_meta($user_id,'committee',true) this is what ...
1
vote
1
answer
108
views
Query multiple post types - Order by type and post title title
I have three custom post types which I need to retrieve posts for within one wp_query. I am seeking to return the posts in the order of post type, as well as by post title.
Within the question ...
0
votes
1
answer
33
views
Sort wp_query of two post types using meta datefield for one and date for the other - possible?
I have two queries that result in id-arrays that I merge into a common array which, in turn, has all the posts I need from the two post types (posts, events). However, in the sorted list I would like ...
0
votes
1
answer
33
views
Conditionaly move certain posts at the bottom of the query result
How can I move certain posts returned by WP_Query to the bottom of the results?
I am using this method..
$exp_args = array(
'post_type' => 'apartment',
'posts_per_page' => -1,
'...
1
vote
1
answer
77
views
WordPress WP_Query custom order_by post_type functionality
I'm on WordPress 6.2.2. I’ve got a query which retrieves content for a given meta value.
$query_posts_for_board_game = new WP_Query(
array(
'post_type' => ['reviews','articles', 'topics'...
0
votes
1
answer
52
views
new WP_Query with order args – no more distinction between categories
I try to change the post order on all of my category/archive pages from the WP standard to having them sorted by their modified date. I modified a part of the loop.php from my theme (derived from ...
0
votes
1
answer
259
views
WP_Query sort by ACF date field (newest first) with blank dates first
I have a custom date field that is optional. If a date is not provided, the item should be first in the items returned by WP_Query. Example:
1st: entry with no date
2nd: entry with date 1 March 2023
...
0
votes
2
answers
227
views
How to put posts with some taxonomy on top of others in `pre_get_posts`
The following tax_query returns only matched posts (with 'matchedstring' IN taxonomy array):
function only_returns_matched_posts( $query ) {
if( !$query->is_main_query() || is_admin() )
...
0
votes
1
answer
55
views
Why does wp_query only display the most recent post when using order ASC?
Problem: I want to list posts of a category, displaying those with custom-field 'start-date' after today (in the future) with order ASC. When this is done, I want to display all those with start-date ...
0
votes
1
answer
124
views
Query order by meta value force specific tag first
I have a custom post type and a shortcode to display a slider. Below is the WP_query code for the shortcode. I'm trying to order a query by tag values. I want posts with a specific tag like for ...
0
votes
0
answers
52
views
WP_Query order posts by category
In a custom WP_Query I want to order posts by category. I mean that I want to show posts with term_id=1291 first and then show other posts.
when I use two WP_Query , I cant use pagination.
"...
0
votes
2
answers
230
views
WP_Query orderby
I am trying to workout the best way to do a slightly abnormal orderby.
I have a query that returns 2 types (Post and Event). As expected by default it orders both, together, by publish date.
What I ...
1
vote
0
answers
68
views
WP_Query orderby author__in
I use WP_Query to get author posts with author ids array order. But it is not getting with true order.
$user_ids = array( 10, 11, 12, 13 );
$args = array(
'order' => 'DESC',
'...
1
vote
2
answers
1k
views
What's wrong with this meta query? (order by meta key, then title, doesn't work)
Here's my meta query:
$taxonomy_term = 1494;
$args['meta_query'] = array(
'relation' => 'OR',
'mp_exists' => array(
'key' => 'tdlrm_mp_'.$taxonomy_term,
...
0
votes
1
answer
265
views
Display Parent-Child Posts in specific order by comparing IDs in array
I have an array of IDs stored for custom post type "service".
Some of these are parent IDs and some of these are child IDs.
So "service" post type here is hierarchical.
Now from ...