Questions tagged [sort]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
28 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 ); ...
Brethlosze's user avatar
0 votes
0 answers
16 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 ...
Tim P's user avatar
  • 1
0 votes
1 answer
32 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' ...
Yehia Gamal's user avatar
3 votes
1 answer
27 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?
Radheeka Chopda's user avatar
1 vote
0 answers
21 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 ...
Enrico's user avatar
  • 11
1 vote
1 answer
22 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'...
DJZEEGLER's user avatar
  • 119
0 votes
1 answer
36 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' => '...
mrtnmgs's user avatar
  • 137
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 ...
Daniel Garcia Sanchez's user avatar
0 votes
0 answers
122 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 ...
JasCav's user avatar
  • 137
0 votes
0 answers
23 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 ...
Gabriel's user avatar
0 votes
1 answer
170 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 ...
Amy Ling's user avatar
0 votes
0 answers
25 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 ...
Mail Mail's user avatar
2 votes
1 answer
78 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 ...
Mac Cooper's user avatar
0 votes
2 answers
343 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 ...
jzn110's user avatar
  • 1
0 votes
0 answers
19 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 ...
Mr.Devops's user avatar
  • 101
0 votes
0 answers
259 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=...
hendra's user avatar
  • 11
0 votes
0 answers
31 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 ...
Nico's user avatar
  • 1
0 votes
0 answers
34 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 ...
Whispar Design's user avatar
1 vote
0 answers
118 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 ...
klewis's user avatar
  • 845
0 votes
1 answer
23 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 ...
vyperlook's user avatar
  • 167
1 vote
0 answers
367 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 ...
Omitheus's user avatar
0 votes
2 answers
283 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 ...
John Aps's user avatar
0 votes
1 answer
58 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. ...
Line One's user avatar
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, ...
Mark Cyzyk's user avatar
0 votes
1 answer
27 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://...
FLX's user avatar
  • 101
0 votes
1 answer
56 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 ...
Terence Eden's user avatar
0 votes
2 answers
31 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 ...
Ann Foley's user avatar
1 vote
0 answers
61 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({ ...
Pacicio's user avatar
  • 21
1 vote
1 answer
1k 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 ...
Mr. Fontastic's user avatar
0 votes
2 answers
231 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 ...
Michael's user avatar
  • 281
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 ...
wooncherk's user avatar
  • 111
0 votes
1 answer
110 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'...
Mario Andthee's user avatar
0 votes
0 answers
162 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 ...
Mastafu's user avatar
  • 45
0 votes
1 answer
792 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 ...
Meghan Prestemon's user avatar
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( '...
vahid sabet's user avatar
0 votes
0 answers
267 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,$...
Vaishali Jasoliya's user avatar
0 votes
1 answer
883 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: ...
Kazimierz Niewielki's user avatar
0 votes
0 answers
251 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 ...
Manish Agarwal's user avatar
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 ...
ergoProxy's user avatar
0 votes
1 answer
66 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 ...
Aleksandar's user avatar
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'] = ...
John's user avatar
  • 1
0 votes
1 answer
200 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' => "...
Dennis's user avatar
  • 135
1 vote
0 answers
68 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 ...
hipixit932's user avatar
2 votes
2 answers
432 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 ...
Naycom's user avatar
  • 23
0 votes
0 answers
232 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 ...
Baim Whello's user avatar
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 ...
zuperuser's user avatar
0 votes
1 answer
247 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 ...
bigdaveygeorge's user avatar
0 votes
0 answers
599 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' => '...
Kenneth Gervacio's user avatar
0 votes
1 answer
47 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(...
Prajwol's user avatar
0 votes
1 answer
582 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, ...
Andrew's user avatar
  • 111

1
2 3 4 5
11