Questions tagged [sort]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
27 views

Woocommerce category page: display Products before Subcategories [closed]

I looked for a solution for hours but I can't figure out how to do it... I have categories that, at the same level, have both products and subcategories. So, as expected, woocommerce display them on ...
0
votes
0answers
24 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
1answer
15 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
0answers
13 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
1answer
42 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
1answer
36 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
0answers
9 views

Sort terms of attributes by date modified or as per user selection, in product backed of woocommerce

Sort terms of attributes by date modified or as per user selection, Right now it is sorted alphabetically when we select any terms from the box in a product backed of woocommerce
0
votes
0answers
13 views

How to change sort order of post type and taxonomy blog pages?

I'm building a site where I need the sort order of the default blog pages to be DESC. I need this for the author pages, all taxonomies and some custom post types. I'm very amateur with php, but I've ...
0
votes
0answers
12 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
1answer
21 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' => "...
0
votes
0answers
42 views

How to get sale product first on category listing page woocommerce?

I want to sort product on category listing page. Want to display sale product first and remaning product after sale product. I have used woocommerce_get_catalog_ordering_args hook for sorting but not ...
0
votes
0answers
20 views

How to order posts in admin list based on custom checkbox field group?

really need a hand with this one. I'm fairly new to PHP. I've added two custom columns to my post admin list. Column A & Column B. All posts will have a checkbox field ('checkboxes') containing ...
0
votes
0answers
13 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 ...
1
vote
2answers
41 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
0answers
6 views

Sorting CPT according to hierarchy in admin panel

I have problem with sorting my custom post type in admin panel. Is it possible to leave children position below parent? I don't know if this is clear, but below I made examples trees. My actual ...
0
votes
0answers
23 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
2answers
572 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
1answer
55 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
0answers
36 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
1answer
15 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
1answer
24 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
0answers
42 views

Sort users list (admin area) by ACF post object/relationship title (not by ID)

I have custom fields for users for example "City". And "City" is a custom post type and in ACF it's using for users as a Relationship/Post object. And if in Users page sort by City ...
0
votes
2answers
158 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
1answer
22 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
0answers
11 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 ...
0
votes
0answers
68 views

WP_Query question: Natural Sort Order for WooCommerce products

I am trying to achieve a natural sort order for the products in our store which have number references such as Nr.1, Nr.2, Nr.13 within the product title but Wordpress/Woocommerce/WP_query whatever ...
1
vote
0answers
22 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
0answers
46 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
1answer
32 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
1answer
40 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
2answers
28 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
1answer
69 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
0answers
52 views

How to add a sorting dropdown to archive pages?

I'm using Twenty Sixteen theme with a custom template for archive pages. What I'm trying to do is to add a sorting dropdown in those pages, like in the attached image. My code skills are very basic, ...
0
votes
2answers
562 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 ...
0
votes
0answers
30 views

Modify $query orderby: If key exists and orderby _sku number

Trying to order the main query in WooCommerce, so it firsts show products with a meta_key called "_stykliste" and next products without each ordered by the "_sku" meta_key. So it ...
0
votes
0answers
31 views

Woocommerce Keep custom Sorting and sold out products in the back - hide theme element

I'm trying to get my products sorted. I've found a code that has multiple been discussed on these forums and on other sites. It works perfect for the sorting. But it targets one of the elements that ...
0
votes
0answers
10 views

Sort Category page items by menu_order for Custom Post Type

How can I change default sorting on Category page listing for custom post type? I would like it to sort by 'menu_order' field.
1
vote
0answers
33 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
1answer
78 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
0answers
19 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
0answers
37 views

Sort by date Function ? post date randomizer wordpress

function pdr_randomize() { $randomize = isset( $_REQUEST['randomize'] ) ? $_REQUEST['randomize'] : ''; if ( isset( $_GET['pdr_rd_nonce'] ) && wp_verify_nonce( $_GET['pdr_rd_nonce'], '...
0
votes
0answers
15 views

How to sort products in shop page by defined category order?

I am currently working on sorting the shop page products based on a defined category order and stock count. I got the stock count sorting working but I am unable to find a proper way to implement sort ...
0
votes
1answer
234 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, ...
0
votes
0answers
94 views

Woocommerce: Adding Date(s) to products and show date in Product Sorting dropdown

We are selling hiking tours with Woocommerce and i would like to add a custom date to a product. Since one and the same tour happen 3 times per season i would like to give a customer a possibility to ...
0
votes
0answers
20 views

How do I sort posts alphabetically but put at the end post names starting with a number?

I have a function that modifies the query and shows posts sorted alphabetically: add_action('pre_get_posts', 'add_post_type_to_home'); function add_post_type_to_home($query) { if ($query->...
1
vote
0answers
22 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
0answers
14 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 ...
0
votes
3answers
45 views

Sorting not working with get_posts

I have been looking at this for hours but can't get it to work. $newsItems2 = get_posts([ "post_type" => "post", "post_status" => "...
0
votes
1answer
27 views

Drop down filter sort posts by latest, last 7 days and monthly

I am trying to use a drop down for users to select and show posts made latest, last 7 days and monthly. Currently I was able to find code to just sort by date in ASC and DESC order. <div id="...
-2
votes
1answer
33 views

have_posts order by title descending

I have custom post type 'movies' listing which i want to order by title, descending. Currently it sorts by post id. The code is: <?php if( $movies->have_posts() ) : ...

1
2 3 4 5
11