Questions tagged [sort]
The sort tag has no usage guidance.
528
questions
0
votes
1
answer
29
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
13
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
0
answers
14
views
How to order query results based on if a custom field has been populated, then the order by the date of the post?
I am trying to custom sort a query for product posts (custom content type) based on if a specific ACF custom field for a product ID number has been populated. My client wants to feature products with ...
0
votes
0
answers
9
views
Sort query_terms_list for post_tags alphabetically
I have the following array that currently sorts tags by tag count and returns the tags with the individual tag count. I would like to keep the individual tag count but sort the tags alphabetically ...
0
votes
0
answers
18
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
28
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
0
answers
12
views
How can i sorting and display image order by siz in media library?
How can i sorting and display image order by size in media library?
Sorting is important for me?
Any one can help me please?
0
votes
2
answers
25
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
20
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
69
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
0
answers
21
views
(WP List Table) How to sort by SKU and Custom Fields?
I created a custom plugin for a client to show all products in a Table. He wants to be able to sort by SKU and some custom fields.
I am using wc_get_products() to fetch the data.
public function ...
0
votes
2
answers
62
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
22
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
0
answers
45
views
Customize the Sorting Dropdown in WooCommerce use another list or more page
it would be great if there was a way to change the default sort by dropdown in WooCommerce on the shop page. but I want to use list page or other page for default sort by dropdown in wp-query.
0
votes
1
answer
43
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
78
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
144
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
0
answers
26
views
Sortable Custom Column?
I'm sorry, I speak a little English.
My MySQL table:
CREATE TABLE wp_visitors (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`post_id` INT NOT NULL
);
The ~/wp-content/themes/mycustomtheme/...
0
votes
1
answer
492
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
110
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
143
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
97
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 ...
0
votes
1
answer
527
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
46
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
16
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
44
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
43
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
143
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
53
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
929
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
102
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
60
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
20
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
30
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
516
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
23
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 ...
1
vote
0
answers
28
views
Sort custom meta column by other meta value
I have a post type named "event" and I store two meta values for these posts: _start_time and _start_time_unix. The first one contains a string representation of a date and the other one a ...
0
votes
0
answers
55
views
Search results sort order failing: set by date only
Hi the default wordpress search seems to be for "piano"
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
WHERE 1=1
AND (((wp_posts.post_title LIKE '%piano%')
OR (wp_posts.post_excerpt ...
0
votes
1
answer
90
views
Sort by price wpdb
I have a page on my wordpress to search for tires everything works fine but I would have liked to know how to add an extra column to sort them also by price.
They can already be sorted by size and ...
1
vote
1
answer
46
views
Sort wordpress custom posts based on meta value
I'm trying to sort the custom posts based on meta value as priority level1, level2 and level3. I have given a dropdown field in post meta as featured posts, standard posts and basic posts. I want to ...
2
votes
2
answers
38
views
Why anything done on comments_array hook gets reset?
I am writing a plugin that will allow simple comment upvoting.
I am trying to sort comments by the number of upvotes. But anything I do on the comments_array Hook gets somehow reset. My question is ...
0
votes
1
answer
166
views
How to sort products by price ASC and place all no price products to the end? (Woocommerce)
I have such trouble, tried a lot of solutions, but nothing worked for me.
I need to show all 'no price' products in the end of catalog, when I am sorting products by price ASC in Woocommerce.
0
votes
2
answers
1k
views
Custom Woocommerce Product Query
I work on a project that shows some travels (depending on the destination category). I try to sort the travels on the start date (var_confirmed_date) but the result is the same as no sorting.
Here is ...
1
vote
0
answers
93
views
WP_Query order by custom field, then randomly order some of results
I'm not entirely sure how to word my question, but I'll give it a go.
Basically, what I'm wanting to do is order a group of posts by a custom field. I have a True/False custom field, created using the ...
0
votes
1
answer
176
views
How sort products by calculate value? ( custom post meta, price, option)
I have options: wz_currency_dollar, wz_currency_euro. And post meta _wz_currency. In the admin panel price of product defined in dollar or euro and select corresponding post meta. In the front-end ...
0
votes
0
answers
30
views
Admin user column sort by numeric meta key
I try to sort a custom user field (team_user_id), I have all data but I can’t sort by numeric.
updated code
add_filter('manage_users_columns', [$this, 'custom_id_column']);
add_filter('...
0
votes
1
answer
421
views
How to sort WP_Post Object array by object field in php?
I have a php code as shown below in which I want to sort WP_Post Object array by object field post_date.
if ( $search ) {
$area_query = new \WP_Query( [
's' => $search,
...
1
vote
0
answers
74
views
Sort the result of the main Query in shop page by a custom taxonomy
In a WooCommerce site, we have products that have a custom taxonomy that are assign to a region.
When the user visits the site, we activate the browser geolocation, and we assign the user a region in ...
0
votes
0
answers
19
views
sort title descending with title with number
please help me,
i have title like this
'1-nen A-gumi no Monster Chapter 2'
'1-nen A-gumi no Monster Chapter 10'
'1-nen A-gumi no Monster Chapter 2'
'1-nen A-gumi no Monster Chapter 1'
'1-nen A-gumi no ...