Questions tagged [sort]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
15 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 ...
0
votes
0answers
10 views

How do I fix this? Sort by rearranges the order of my Product Categories in the left side widget [closed]

I used a plugin called Custom Taxonomy Order NE to rearrange the order of my Product Categories (commonly seen on e-commerce websites on the left sidebar). I used a widget for the Product Categories &...
1
vote
2answers
61 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
49 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
30 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
9 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
20 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
13 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
71 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
18 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
38 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 ...
0
votes
0answers
19 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
1answer
40 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
29 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
34 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
27 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
24 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
50 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
131 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
29 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
16 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
7 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
29 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
36 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
16 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
28 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
12 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
116 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
22 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
17 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
19 views

Unable to ORDER BY numbers

I am using WPTables to display data in a mySQL database, it all works fine and without issues, the problem is it sorts oldest first, I need to sort by newest first, here is an example: http://...
0
votes
0answers
14 views

WP_Query orderby meta_value Speed

I currently sorting my posts using this code: function main_query($query) { if ( is_search() || is_home() || is_front_page() || is_archive() ) { if (!is_admin() && $query->...
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
38 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
0answers
9 views

How do you create a series of buttons to filter by category tags?

I am making a website to sort classes The structure I currently opted for was to have pages that correspond to the discipline - e.g. Computer Science The post would be the course e.g. Introduction ...
0
votes
0answers
13 views

Alphabetical taxonomies and pre_get_posts not working

I am currently building a website that makes use of a theme. The theme has a custom taxonomy called team_group. I created a custom template called taxonomy-team_group.php to be able to list the posts ...
0
votes
1answer
18 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="...
0
votes
0answers
19 views

Sort products by category name

I would like to sort my catalogue by category name. Some of my products have the category "top" that I would like to be displayed at the beginning of the catalogue. There's also already a sort by date ...
0
votes
0answers
14 views

Sort wp_query by variable created inside the loop

I have a custom loop that pulls all the child pages of the current page, and displays them. However, I need to order this query by the $first_row_image variable that is created inside the loop. This ...
-2
votes
1answer
31 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() ) : ...
0
votes
0answers
12 views

Is there a way display only certain blocks depending on user selection?

I have a long page, with a lot of blocks showing different resources for different cities. I would like to categorize them, so that a user can see only the resources that apply to them. At the top of ...
1
vote
0answers
46 views

WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC

I'm trying to set up a query for an "event" custom post type that groups posts by year, with a heading for each year, in descending order; then, for each year group, ordered by date in ascending order ...
1
vote
1answer
244 views

Meta query with order by another custom field

Edit: I will try to explain in detail my problem. I am working on a portfolio site. There are a few custom post types: Projects, Publications, Exhibitions, Lectures and Slides. Home page consists of ...
0
votes
0answers
144 views

Get authors list and sort them by recent posts

I have a authors list and its sorted in the alphabetical order. The query for it is here $user_args = array( 'orderby' => 'display_name', 'order' => 'ASC', array( 'who' => '...
0
votes
1answer
30 views

Listing Cities A custom taxonmy by selection order

I have below code that lists cities in ascending order, I want to lists cities based on the order I select the cities from the frontend. It is a shortcode created by theme. Cities is a custom taxonomy ...
0
votes
0answers
16 views

wp-admin: retain category hierarchial structure when sorting

By default, the category page in the admin backend sorts categories in alphabetical order preserving the parent->child hierarchy. When sorting categories e.g. by count the hierarchy is lost. All ...
0
votes
0answers
23 views

How to sort by a custom “text” date field in mmddyyyy format

I'm having issues sorting by a custom date field on my WordPress website. I'm not a WordPress coder by any means, and i'm working with a previous owner's code. Basically the field is an ACF text ...
0
votes
0answers
51 views

tax_query and sort by meta_key - no results

I have query: $tax_query = array( 'relation' => 'AND'); $tax_query[] = array( 'taxonomy' => 'kategoria', 'field' => 'id', 'terms' => $term->...

1
2 3 4 5
11