Questions tagged [sort]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
25 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
28 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
22 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
12 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
40 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
57 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
21 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
13 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
28 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
12 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
12 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
26 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
11 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
48 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
11 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
16 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
12 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
13 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
34 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
7 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
15 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
18 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
10 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
2answers
30 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
11 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
41 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
147 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
99 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
27 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
14 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
21 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
41 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->...
0
votes
1answer
38 views

Sort custom post type by custom datepicker instead of filtering

I have a custom post type Event that I use in conjunction with ACF. I have a group called event and inside that group I have a field called date_start. And this is the code that I currently have, but ...
0
votes
1answer
23 views

Sort custom post type by most current date picker

I'm trying to sort custom post type made with ACF plugin by most current date. Ideally future most current post should be first. Currently, I'm sorting by date, which gives me the earliest post as the ...
0
votes
1answer
89 views

Move some posts to end of sort order, even if there is a sort in the wp_Query already

I have a site that lists properties for sale. I have a custom wp_query, with a sort dropdown I created. This dropdown reorders the posts query by date, price (low-high & high-low) and beds (low-...
0
votes
1answer
64 views

replace text in Sort Box

I have renamed the woocommerce sort options to remove the default "Sort by" preceding all of them. However I would like to rename the text in the box at the top to “Sort by", so that the selected ...
0
votes
1answer
141 views

Rename WooCommerce sorting dropdown options [closed]

How to rename the WooCommerce sorting dropdown options and customise the wording? For example, change "Popularity" to "Best Selling" or "Price: Low to High" to just "Price Low to High" without the ...
0
votes
0answers
50 views

How to sort by multiple values in a nested WP_Query

I am displaying courses, enrollment, along with rooms whose capacities are greater than or equal to the enrollment. This query works, except the 'order' => 'DESC' for courses, and 'orderby' => '...
0
votes
0answers
42 views

How to get ordered fields from repeateble fields group added via Toolset wordpress plugin?

I got 2 fields in group ordered by toolset-post-sortorder meta_key: youtube_id: TeBW-WByzlw 144 163 youtube_id: CEdYPEKDD2E 255 270 This it how it look in DB: This is how I try to get fields: $...
1
vote
1answer
104 views

Sorting category products not working

I am using Avada theme and the sorting of the products on category page is not working. When i click on ascending and descending order the ordering of the products becomes random. Please provide me ...
0
votes
1answer
59 views

Custom post type order by post_title

I got a custom post type called "employees" and this is the query I use with FacetWP (plugin we are using). We want to sort the employees by post_title. <?php return [ "post_type" => [ "...
0
votes
1answer
225 views

How to Sort Products by “Featured” first?

I would like the default sort method of my product archives to display all the featured products first, and then display all the other products as normal. I'm not sure if there is a hook for this or ...
0
votes
1answer
17 views

How to sort post category using its Description

I Am trying to sort my custom post categories according to its description. I tried below args but it did not work $taxonomies = array( 'post_tag', 'product-type', ); // Add the slugs of ...
1
vote
1answer
51 views

Advanced search by two criteria - sort by location and date (ascending or descending)

I have spent a couple of days working on this and I am still not able to figure it out. I am trying to make advanced search filter that sorts posts from a specific category on two criteria: location (...
1
vote
1answer
86 views

Order wordpress taxonomy parent terms by their children count

I need to order parent terms by their children count: function sort_terms_by_children_count ( $terms ) { $sort_terms_by_children_count = array(); foreach($terms as $term) { $count = ...
0
votes
1answer
184 views

Orderby event date (if it exists) or post date (if it doesn't) - how to reorder posts based on meta value OR date

I need a way to sort the posts on my tag and category archives according to the event date (if it exists) OR post date (if it doesn't). I have a combined archive for events and posts, but want to ...

1
2 3 4 5
11