Skip to main content

All Questions

Tagged with
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 ...
LBF's user avatar
  • 529
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 ...
Allen Tullett's user avatar
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 ...
yms's user avatar
  • 35
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, '...
Abhik's user avatar
  • 2,911
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'...
commadelimited's user avatar
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 ...
Frank Wagner's user avatar
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 ...
Space's user avatar
  • 129
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() ) ...
mikmikmik's user avatar
  • 101
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 ...
hal's user avatar
  • 35
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 ...
Biels's user avatar
  • 113
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. "...
Siavash's user avatar
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 ...
DrogoNevets's user avatar
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', '...
wpuzman's user avatar
  • 111
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, ...
Artem's user avatar
  • 305
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 ...
aslamdoctor's user avatar

15 30 50 per page
1
2 3 4 5
14