All Questions

Tagged with
Filter by
Sorted by
Tagged with
0
votes
1answer
40 views

Order by value of Custom Field using url string

I have a simple dropdown: <select class="dropdown-class" name="sort-posts" id="sortbox" onchange="document.location.search=this.options[this.selectedIndex].value;"> <option disabled ...
0
votes
1answer
20 views

query posts with selected post ids first

Is there a way I can get most recent posts with a couple of posts I specify by post ID listed first? According the docs, the order and orderby parameters may be passed as an array, so in theory I'm ...
0
votes
0answers
14 views

Sort posts by number of times tagged [duplicate]

Let's say I have a custom post type Books, and I tag the books with a custom taxonomy "Person". The taxonomy contains the name of a person and basically means the person has read that particular book. ...
0
votes
1answer
11 views

Order by meta date with a thousanth of a second defaults to post order

I have a custom post type query: $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'paged' => $paged, 'post_type' => 'my_custom_post_type', '...
0
votes
1answer
25 views

WP Query with meta queries

I have the following WP_Query: $query = new WP_Query(array( 'post_type' => 'some_cpt', 'posts_per_page' => -1, 'meta_key' => 'active', 'meta_value' => 1, '...
1
vote
1answer
69 views

Change default ordering of taxonomy terms - pre_get_terms

I wanted to change the default taxonomy terms order by its 'term_order' value instead of 'name' in admin side. So I tried something like below. But it doesn't work and php memory exhaust. function ...
0
votes
0answers
33 views

Order Element By Custom Field in Wordpress

I'm working on wordpress and I want to order my post by rating. I'm new with it, and I need some help. I tried many things, but seem it's not working :/ My Wordpress Custom field which contain the ...
0
votes
1answer
74 views

Debugging wp_query orderby for taxonomy

I cannot seem to find where WP_Query adds the orderby clause to a SQL query. I am using this code: function wpd_team_taxonomy_queries( $query ) { if ( !is_admin() && $query->is_tax( 'team'...
0
votes
0answers
17 views

Query Order By Number Variable From API

Trying to order the query by a number variable $total that is a storing an api containing a number. My goal is to output an ordered list with the number ($total) sorting the list. I've looked around ...
0
votes
0answers
190 views

How to get_comments() ordered by date and parent?

So my starting point is: <?php $comments = get_comments(array( 'post_id' => $post->ID, 'status' => 'approve', 'type'=>'comment', '...
0
votes
0answers
59 views

WP Query to order posts with a specific meta value first

I am trying to write a WP post query to get all posts which have a certain meta key, but with those which have the key set to a specific value to show first. The query modifications are in a ...
1
vote
1answer
197 views

Order by summing multiple values

In a custom post type (products) I want to order products by summing multiple values based on user selection. I use custom taxonomies to filter the products. I could use the orderby meta_value but ...
1
vote
0answers
29 views

Understanding the orderby in WP_Query?

For quite a while I have been trying to query posts, with 2 different meta_queries, and order them differently. I followed the WP codex. Recently I have found out that I have been mistaken this ...
0
votes
3answers
242 views

WP_Query not resetting after wp_reset_postdata

I have this custom query: if (isset($_COOKIE['myCookie']) && $_COOKIE['myCookie'] == $f_r) { $args = array( 'posts_per_page' => 4, 'nopaging' => false, 'order' => ...
0
votes
0answers
45 views

Order 2 meta_queries differently in WP_Query?

I have a custom WP_Query with 2 different meta queries. I want to order the results of both queries differently. The first meta_query I want to order by a custom field (high integer - low integer). ...
0
votes
1answer
149 views

Wp Query sort order from custom MetaBox

I am trying to sort a list of post based of the meta_key deal amount, which would be to display the highest deal first and work its way down to smaller deal amounts. The deal amount would be anywhere ...
0
votes
0answers
29 views

Sorting with meta_query and multiple, optional meta keys

I'm trying to sort a custom post type by 3 properties: Meta Key: is_featured Meta Key: is_primary Title The two keys are boolean ACF items, and are both optional, so most of the posts don't have the ...
0
votes
0answers
24 views

Order by date with more than one meta key in Wordpress query

I have a list of events and they all have either a 'start date' or 'date'. I am trying to list the events in order using either field depending on which is filled out but am having no luck. I tried: $...
0
votes
0answers
77 views

WP Query. Ordering posts by another post types meta

I have a custom post type called BID which contains a users bid (similar to freelancer.com, upwork, etc) However I need the BID results on the page to be ordered by meta stored in a users profile, ...
0
votes
2answers
92 views

(Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array

I'm developing a system where I have a Deck presentation. I have a field that takes the post by the 'copas' type of card being within the 'meta_value' array specification, and I would like it to be ...
0
votes
2answers
2k views

how to get post order by post id wp_query?

i have 4 post and i displaying 2 post per page. $ids = array('16085','16088','16083','16091'); $options = array( 'post_type' => $post_type, 'posts_per_page' => $posts_per_page, ...
1
vote
1answer
113 views

How can I pick a single post from the latest 3?

I'm looking to display a single featured post from my latest 3 posts at random. I've managed to get it up and running picking any post at random just fine, but I want to filter it down to only the ...
1
vote
1answer
111 views

Order by empty custom field

I order my posts by custom field faq-order. That's work for me: $faqArgs = array( 'post_type' => 'faq', 'meta_key' => 'faq-order', 'order' => 'ASC', 'orderby' => '...
-1
votes
1answer
242 views

orderby and order filter in get_posts or WP_query function in wordpress not working

I have function in wordpress plugin which queries the posts using get_posts($array). But I wanted this to orderby post_modified field of the posts table in DESCENDING order, for which I have this code ...
0
votes
1answer
483 views

WP Query - order posts by meta field first and then order the rest

I'm trying to order product post type with custom meta field for an expiration date. I want to show all the expiring products (first being the expiring soon ones). After them, I want to show all the ...
0
votes
1answer
238 views

WP_Query: custom orderby (not ASC nor DESC)

How do I get a custom orderby in WP_Query (not ASC nor DESC)? So, order have to be not alphabetically, nor numerical. It have to be custom. For example I want to sort by post's meta field thing in ...
0
votes
1answer
44 views

Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday

I have a code which sorts the content by most liked, but I would like it to show the most liked in between previous week monday and next week monday. And the posts must be published in that time frame....
1
vote
0answers
190 views

WP_Query with tax_query, order by most 'matches'

TL;DR: How can I sort a WP_Query based on how many 'matches' there are on the tax_query set. Furthermore, how can I then add more posts if the posts_per_page is not met due to the tax_query added? ...
0
votes
1answer
43 views

Best way to query posts and order by relevancy to query

I want to query a custom post type that has 100+ associated categories. The query will be based on values in the current user meta, specifically, the user will have preselected categories they want to ...
1
vote
1answer
376 views

Wordpress WP_Query orderby being overwritten

$args = array( 'post_type' => 'mcm_company', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => '1000', 'post_status' => 'publish', )...
0
votes
1answer
925 views

Order Posts by meta value AND published date

I want to order WP posts by meta key named "sort_date" and if it doesn't exist it should use the post's published date to order posts. Below is the code i am currently using function ...
0
votes
1answer
667 views

WP_Query sort by meta_value_num or date

I am using meta_value_num to sort posts by price and allow users to use a dropdown to change between max and min. What I need now is the ability to select from Min Price or Max Price or Newest Posted ...
4
votes
1answer
7k views

WP_Query order by multiple meta keys & fields

How to order query by multiple meta keys and fields/custom fields? This is my code: $args = array ( 'post_type' => 'listing', 'posts_per_page' => -1, 'tax_query' =&...
0
votes
1answer
882 views

Order by the results of a function with WP_query

I am attempting to order the results from WP_query by a custom value. Specifically, I want to use the name field, however, the name field is going to be made up of many words separated by spaces. I ...
1
vote
0answers
346 views

Order Custom Post Type by Custom Field Value

I'm having trouble getting my custom ordering to work. I'm trying to order a custom post type by a custom field called feature_order which is a numeric field (created with Advanced Custom Fields ...
0
votes
1answer
561 views

Order & Orderby clause not working with custom query

I'm having an issue with the order of search results loaded via AJAX, it never matches the order of the same query on the search results page. The AJAX response WP_Query instance uses the following ...
0
votes
3answers
50 views

Ordering posts by an array

I have a query that returns a number of different custom post types. I want to order the array of posts by the content of an array of post types; e.g. array('post', 'video', 'testimonial'..... ); The ...
1
vote
1answer
3k views

Orderby ASC changes to DESC in WP_Query

I am trying to get posts in Ascending order using WP_Query, $args = array( 'date_query' => array( array( 'year' => $ppy, 'orderby' => 'post_date', ...
1
vote
1answer
356 views

How can I order Wp_Query hierarchically?

I have a cpt for which I need to order Wp_Query hierarchically... Example: Show 1 Episode 1 Episode 2 Show 2 Episode 1 Episode 2 I thought order_by=parent would do it, but apparently not so.
0
votes
0answers
63 views

How to order posts, that have already been filtered by custom taxonomy, by their category names?

My question is not a duplicate, because in my case posts have already been sorted by custom taxonomy term. The question is how to order posts by their category name AFTER they have been sorted by ...
0
votes
2answers
327 views

wp_query sorting – one specific meta_key value at last and then sort by create date

I'm having a custom post type "products" of which I need to show a list. The products are sorted by meta value into different kinds of product type. I need to set one specific product type "tools" at ...
0
votes
1answer
55 views

Need to know custom code to display random and most viewed posts in wordpress posts and pages

My focus is to use custom but an optimized code to display random and top posts/pages in my WordPress. I have seen some recommendations where people refer to plugins, but I need codes/query only.
3
votes
0answers
846 views

Show all parents and children in custom post type in right order

I would like to show all posts from a custom post type on one page with the ordering exactly like in the backend. I get the right ordering with wp_list_pages, but of course without the content. ...
1
vote
4answers
3k views

How to order posts by title after they have already been sorted by category

I'm not an expert at much, so please excuse me if this is an easy question... but it's got my head spinning. I have an archive template (adapted from a standard 'enfold' theme template) which I am ...
0
votes
1answer
302 views

How to Create a Random List of Child Pages

I have a site that has Parent and Child pages. I want to be able to show a list of the child pages, listed in Random order. In addition I want to limit the number of child pages shown. I have found a ...
0
votes
1answer
1k views

query_posts based on a meta_key

I have custom post type of brand and custom field generated via types plugin, wpcf-sorter trying to manually create a field to sort my posts. Some of the posts have this custom field populated with a ...
0
votes
1answer
2k views

Wp query orderby 'title' doesn't work

I would like to order a list of post title alphabetically. I am using this specific query // WP_Query arguments $args = array( 'category_name' => 'reportage', 'order' =&...
0
votes
1answer
166 views

Order by 's' using WP_Query()

I have a wp query like this, $args_search = array( 's' => "string1 string2 string3 ..", 'post_type' => array( 'post' ) ); $wp_query = new WP_Query( $args_search ); This will search for ...
1
vote
1answer
245 views

SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)

Hey there I have the following SQL Query which is generated by WP_Query numeric meta query: SELECT SQL_CALC_FOUND_ROWS wp_postmeta.meta_value FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = ...
1
vote
1answer
55 views

Order WP_Query by multiple fields, subtracting them from one another

I have two custom fields for each post, vote_up and vote_down. I know how to order by one of them, but I'm wondering how I can get the totals of both, subtract vote_down from vote_up and then display ...