Questions tagged [sort]
The sort tag has no usage guidance.
541
questions
0
votes
1
answer
30
views
Elementor - Sort by name
I have a website that lists paintings. All these paintings are made by various artists. I've added a custom post type "paintings" and created a form so each painting can be easily entered. ...
1
vote
1
answer
43
views
query loop "inherit query from template" prevents setting sort order
I need all auto-generated category pages to sort oldest-to-newest
I'm editing my "All Archives" template in block editor but I'm not having any success
it contains a query loop with "...
0
votes
1
answer
156
views
posts_results filter - additional sort, with a meta value, to move posts to the end of the results, with pagination working
I have a custom post type for business locations that I am trying to add an additional sorting filter to by using a custom meta value. The custom field specifies whether or not the location is open or ...
0
votes
1
answer
35
views
Sort Featured Content by Order instead of ID
I am generating a Featured Content with the following code:
<?php
$featured_posts = get_featured_posts();
foreach ( (array) $featured_posts as $order => $post ) :
setup_postdata( $post );
...
0
votes
0
answers
20
views
Sort WooCommerce categories automatically into friendly-looking tree
have a problem, I've uploaded bunch of products into WooCommerce store via XML file. Something like 45,000 products and xml didn't had certain category for every product, instead it had meta tag with ...
0
votes
1
answer
38
views
WP Query order posts not working
Hello I have custom wp query
$args = array('post_type' => 'marketing_en',
'tax_query' => array(
array(
'taxonomy' => 'custom_post_type',
'field' => 'slug',
'terms' ...
3
votes
1
answer
32
views
How can I change the post order after filtering in WordPress?
After filtering the post list in the admin dashboard, how can I change the order of posts after filtering and it will display in the same order at the front end too?
1
vote
0
answers
22
views
Admin custom post ordering
I'm trying to order custom posts in admin page using an acf date/time value,
I've found a useful resource on wpmunchies.com
I've made some changes, so my code is the following:
function ...
1
vote
1
answer
41
views
How to `'orderby' => 'meta_value_num'` in a series of orderby parameters
I'm running a site for a book store. Each book has a catalogue number. These numbers are often a string with numbers in it. For example- PUB 1 would be a common entry, as well as PUB 12. Right now, it'...
0
votes
1
answer
50
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
20
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
173
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
24
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
205
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 ...
2
votes
1
answer
114
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
455
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 ...
1
vote
0
answers
128
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
1
answer
24
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
404
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
338
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
63
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
29
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
64
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
33
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
65
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({
...
2
votes
1
answer
2k
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
246
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
134
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
176
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
910
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
2k
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
290
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
970
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
264
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
2k
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
69
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
24
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
249
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
87
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
473
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
235
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
937
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
275
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
684
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
55
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
664
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
3
answers
1k
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
50
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($...