Questions tagged [sort]
The sort tag has no usage guidance.
540
questions
0
votes
1
answer
22
views
Sort by multiple columns using get_posts
I have the following:
get_posts(array(
'post_type' => 'event',
'posts_per_page' => -1,
'meta_key' => 'start_date',
'orderby' => '...
0
votes
0
answers
18
views
Sort by price when price is set in multiple keys
I am performing a query, using WP_Query.
I am trying to sort products by price ( from lowest to highest ), and I have a problem, namely that the price value is set in the key "_price" in ...
0
votes
0
answers
19
views
Sorting by Title for Post Archive Categories for Custom Post Type
I have a custom post type - vendors. They have a taxonomy vendor_category. I am attempting to sort the archive pages by the title (since it defaults to post date). Here is the code that I am putting ...
0
votes
0
answers
21
views
What is wrong with my sorting logic?
Trying to sort a custom query. I need the values to be sorted based on the menu order. The following code prints out all the values as expected, but not in any sorted order. I'm trying to get the ...
0
votes
1
answer
60
views
Sorting Users page admin column with ACF field
I have a CPT called Companies. I created an ACF relationship field called user_company that gets displayed in the Users profile page.
When a user registers, I have to go in and assign them to a ...
0
votes
0
answers
11
views
Custom product sorting archive page
I would like to create a sorting products custom.
The result I would like is the following
all featured products
Most sold products in the last year
All other products.
Is it possible to do ...
2
votes
1
answer
44
views
Custom taxonomy with custom meta value is not sorting correctly (query returns the same value for orderby regardless of sort column click)
I have a weight class category, where I want to sort by weight so Heavyweight shows at the top, and Flyweight at the bottom. I have created a custom meta field called 'weight' where I store an int ...
0
votes
2
answers
82
views
How to sort posts alphabetically based on a specific parent category
I'm building out an index page of posts that are grouped under multiple categories, but those categories are all under the same umbrella parent category.
I'd like to have these posts displayed ...
0
votes
0
answers
18
views
Sort posts by Date (DESC) and by ACF: active_inactive (ASC)
I am trying this but does not seems to work. I can make them work individual, but together i am not able to sort the posts by post created date and ACF field active_inactive.
function ...
0
votes
0
answers
105
views
Woocommerce backend sorting product drag drop by menu_order to date
is it possible to change the backend drag and drop product sorting to sort by date instead of the default sorting by menu order
by default is short by menu_order
this page:
wp-admin/edit.php?post_type=...
0
votes
0
answers
19
views
Sort Category Archive pages and place sticky posts first
I have a very simple request: I want to sort my posts within the category (or tag) archive page by date (which is the default), but put all sticky posts first.
I found working code snippets for ...
0
votes
0
answers
23
views
Sort CPT by taxonomy AND THEN by custom field
I am trying to sort a CPT first by Taxonomy (tag) ASC and then by custom field (last_updated_hc) DESC which is a date-picker field. Using posts_orderby I can sort by taxonomy but I am running into ...
1
vote
0
answers
66
views
Custom order of CPT posts by title, in wp-admin area by default
Its tough to know/determine/see if a plugin is ever overriding or will override my ability to use $query->set('orderby', 'title') when I am attempting to sort my admin posts by title, for my ...
0
votes
0
answers
20
views
WP_Query – order with usort by custom meta
I have a custom post type location which has different categories (e.g. museums, theatres, shopping) and I want to output each of these categories and order within these categories by distance which ...
0
votes
0
answers
22
views
Wordpress Feature - Multi Level sorting
I am developing a Wordpress site with WooCommerce and would like to implement a multi-level sorting feature. This would sort first by one parameter (for example, price), then AFTER that sorting sort ...
0
votes
0
answers
19
views
Sort Search Results in Order of/by Character @ count (9) of post(s) title. (Ocean-WP theme)
I'd like to order Search Results by the 9th character of Post title.
Example) Search Results Page:
Current Order:
123456 - B Post Title;
678901 - A Post Title;
789101 - C Post Title;
891011 - 1 Post ...
0
votes
1
answer
17
views
change the default order of posts only for specific categories
I want to change the default ordering for posts, to last modified date, but only for certain categories pages (when visiting certain category pages)
I have this function code, which is working, but I ...
1
vote
0
answers
294
views
Compare ACF date field (if exists) and post date and order DESC
I have an ACF date field (same format as post date) and in my Query I want it to be compared to the publish date of the post:
If erstelldatum is not empty use erstelldatum for order
If erstelldatum ...
0
votes
2
answers
170
views
Next/Previous Product with custom order by price & products inside the product category [closed]
How to create next/prev buttons that are price sorted and give results inside the product category you are in?
This question has been asked multiple times and despite the multiple threads there wasn't ...
0
votes
1
answer
54
views
Sort users by meta key value even if meta key not present for all users
Only some users have a specifice meta_key some_metakey associated with their ID.
The following args successfully orders users with a specified role by some_metakey but only those with that meta_key.
...
0
votes
1
answer
16
views
WP_Query, Taxonomy, list of attached items to a Term, sorted
I have a Taxonomy, “Genre”.
“Genre” has a Term, “advert”.
I want my taxomomy template to grab all Custom Posts attached to that term, sort them by my last_name, first_name, short_title Custom Fields, ...
0
votes
1
answer
25
views
Table Sorter sort by span title?
I'm using table sorter plugin to sort a table on my website.
One column has only unsortable signs as content.
However I'm trying to sort this column by value.
It's the column IMDb here: https://...
0
votes
1
answer
40
views
Sort scheduled posts in ascending order by default
I have a self-hosted WordPress blog (5.9). When I go to view scheduled posts, I want the default sort order to have the soonest scheduled posts on top.
I can do this by manually hitting the date ...
0
votes
2
answers
30
views
Custom Post Type page sorts differently on different environments
TLDR: My custom post type items are sorting differently on a local environment and a live server. Can't figure out why!
I have a local install (MAMP) and an online dev install (GoDaddy shared, for the ...
1
vote
0
answers
54
views
How to enable sorting in custom media uploader in plugin
In my plugin I need a media uploader exactly like the one you see when you select a post's featured image.
I managed to do almost everything with this code:
media_uploader = window.wp.media({
...
1
vote
1
answer
969
views
Show Primary Category first when I display post categories
I created some custom taxonomies in Wordpress and when I want to show the categories for a custom post type on the frontend, they're listed in alphabetical order.
Is there a code for functions.php ...
0
votes
2
answers
165
views
Posts sortable column not sorting properly for custom field numbers
I have a custom field for view counts that are stored as numbers. I added a Views column, and made it sortable, but they are not sorting properly.
The results when I click on the Views column are ...
1
vote
1
answer
29
views
Order By Post Type ThenBy Taxonomy
Assuming I have these custom post types:
Product
Video
Article
And for Product (WooCommerce Product), we have many Categories, one of which is called "Parts".
I have this situation where I ...
0
votes
1
answer
78
views
Sort custom posts by date and then by taxonomy
i am having this issues for month and i can't figure out how to solve this one:
I am working on a website, where you can check out cultural events in my region. This is just to let you know of what i'...
0
votes
0
answers
114
views
Order (by ASC) posts with meta_key so posts without values are last
I am trying to figure out sorting posts with prices in one meta query, so the posts without prices are shown last, when ordered by ASC and not first.
Right now I am temporarily not showing posts ...
0
votes
1
answer
539
views
Sort categories by custom field in WordPress admin
I know there are a lot of threads about similar issues, but I can't figure out why my custom sort won't work in the category admin page. Here is my code to add the ACF field as a column to the ...
0
votes
1
answer
1k
views
Sort products by Sale price and stock status
I want to sort products by sale price and in stock and regular price at first but doesn't find solution anywhere. Here is what I have implemented and didn't get the solution:
add_filter( '...
0
votes
0
answers
220
views
How to sort store location by specific category order in WP store locations
i want show if store has specific category then should be show in first and then order by distance
add_filter( 'wpsl_sql', 'custom_sql' );
function custom_sql() {
global $wpdb, $wpsl_settings,$...
0
votes
1
answer
614
views
Woocommerce - Problem sorting and filtering products with different tax rates by price [closed]
Setup (wordpress and woo only; fresh install):
Prices entered with tax: No, I will enter prices exclusive of tax
Display prices in the shop: Including tax
Display prices during cart and checkout: ...
0
votes
0
answers
206
views
wanted to sort the wp_query array by two ACF field (Year and month)
Want to sort the wp_query by two acf field i have created month and year, my problem statement is there are multiple post(newsletter) where they have two ACF fields month and year. I able to sort them ...
1
vote
1
answer
1k
views
Wordpress sorting posts by date and title using a dropdown
I'm trying to set up a dropdown that would sort my posts by Newest to oldest and Alphabetical.
This is what I have so far:
I'm declaring an empty variable, then a form where I can change the contents ...
0
votes
1
answer
59
views
Custom sort comments with select form
I use ACF Pro to create a customized comments section with additional fields to my custom post type called Products (it's a simple page with a custom comment section, NOT using WooCommerce).
Now ...
0
votes
0
answers
23
views
make two custom columns sortables
I have 2 custom columns, typeconsole and console:
add_filter('manage_edit-post_sortable_columns', function( $columns ) {
$columns['typeconsole'] = 'typeconsole';
$columns['console'] = ...
0
votes
1
answer
116
views
Order posts ascending from posts in array
I have all my post id's in a specific array $productIds. When I want to show only these posts, I do this query:
$args = array(
'post_type' => 'Product',
'orderby' => "...
1
vote
0
answers
57
views
How to redefine the sorting of product categories by menu_order?
With the help of elementor and jetengine from crocoblock, I display product categories. These categories are sorted by the date they were added, but I would like them to be displayed in the order in ...
2
votes
2
answers
323
views
Sort products without thumbnail in WooCommerce shop page
I would like to create a function that instead of hiding the products without thumbnails, would be ordered in such a way that the products with the highlighted image appear first on the shop page ...
0
votes
0
answers
216
views
Order column custom date using pre_get_posts
How I want to sort my custom column contain string date with format j F Y
my column data contains string example "21 januari 2021", how I can change the format to date so I sort it.
My value ...
1
vote
2
answers
933
views
Combining sorted and random CPT
I have two Custom Post Types and would like to display one of them sorted (by title) and the other one at random places in the same query.
So CPT A (sorted) en CPT B (random):
A1 A2 A3 B2 A4 A5 B5 A6 ...
0
votes
1
answer
192
views
Custom post type sortable columns when column value is from a custom database value
I have a custom database table called views containing product IDs, an overall view total and a number of other columns.
I have written the following code where I was attempting to add a column in the ...
0
votes
0
answers
394
views
how to include orderby value that is empty?
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'meta_query' => array(
array('key' => 'release_date',),)
, 'orderby' => 'release_date title','order' => '...
0
votes
1
answer
28
views
How to display remaining post ( in post__in ) if posts are less then post per page?
I am sorting product on product category page. I want to display sale product at first and show remaining product after it. I am using pre_get_posts hook to modify query.
My CODE
function modify_query(...
0
votes
1
answer
315
views
How to sort wordpress posts already selected by WP_QUERY
English is not my first language, sorry :)
I need differend per paginate page sorting.
For exemple, I created the loop:
$qargs = array(
'posts_per_page' => 15,
...
0
votes
2
answers
957
views
'sort_column' => 'menu_order' not working
We have a simple plugin to display a tree menu, which includes the parent page, plus the parent page's children (so, the siblings of the current page).
We're using the following get_pages code:
$pages ...
0
votes
1
answer
47
views
How to sort by number
I have to sort my results by number:
<ul>
<?php $productTerms = get_terms('prezzoceste', array('hide_empty' => 0, 'orderby' => 'ASC', 'meta_type' => 'NUMERIC', ));
foreach($...
1
vote
0
answers
16
views
User Query sort on custom field then name
I am trying to sort a list of attorneys (set up as Users) classified as founding members, members, and associates. Those classifications are stored in the attorney_title meta field.
I need them to ...