Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sort]

The tag has no usage guidance.

1
vote
1answer
18 views

Sort by two dates. Default entry date and custom field if present

I have a custom post type where there is an option to sort by date. There is however a custom date field that allows changing the display date. This custom date field is not always filled. Right now ...
1
vote
2answers
108 views

Sort in WP_Query(), not filter? Is it possible?

I want to query and SORT in WP_Query(). But whatever I do, it only prints posts with meta_key set up. But I want all the results and just sort them. This is my query: $query = new WP_Query(array( '...
0
votes
0answers
24 views

Display and Sort Tags by Last Word / Name

I have a page which lists all tags (artist names) for a certain category along with links to that artists work. Each post only has one tag if that helps simplify things. I am trying to order the tags ...
0
votes
1answer
17 views

Sort populated GravityForms list alphabetically [closed]

hope someone can help a newbie because I'm stumped on how to do this. I've got the following code in my functions.php that populates a GravityForms form "checkbox list" of products. The user selects ...
0
votes
0answers
5 views

Is there a way to execute a function whenever Gutenberg Blocks are rearranged?

i'm having the following problem: I have created a grid component which uses a binary packing script (packery by metafizzy) to fit its child blocks depending on their size. To improve the editing ...
0
votes
0answers
13 views

Is it possible to autosort tables in the visual editor?

A client asked if the tables in his Wordpress editor could be sorted alphabetically automatically. He asks because the tables are quite long and it would be easier for him to edit them this way. (I ...
0
votes
0answers
14 views

WooCommerce product sorting VERY slow

I have 2800 products in my WooCommerce store. Trying to use the All Products > "Sorting" utility in the backend to edit the desired order for them to appear is excruciatingly slow. Even if I filter ...
3
votes
3answers
71 views

Filter admin columns by custom post field value

I have a custom post type called dogs. Within the Add Dog interface, I have a radio-button group that gives choices for color, which are added to the new dog post as meta data. There are about five ...
1
vote
1answer
29 views

Admin multiple column sorting

This question seems simple enough, and I'm surprised that I don't find much while searching Google to find an answer. The only thing I've found is a pro plugin, so far. I'd just like to be able to ...
0
votes
0answers
24 views

Changing WP_Query params with url Query Var

:) I've used WP_Query to display there posts (travels) here http://boost19.delavec.si/wordpressP/produkti/ So... I've got this WP_Query that is looping through my custom posts <?php $paged = (...
0
votes
1answer
17 views

Sort by promo code used woocommerce admin panel [closed]

I work on Woocommerce / Wordpress and I'm new, I want to custom my Woocommece orders list admin panel by adding the used coupons inside it, but I've got a little problem when i click on promo field ...
0
votes
1answer
23 views

how to develop a filter in wordpress to let the user filter the page content depends on the date (newest to oldest etc…)?

how to develop a filter in WordPress to let the user sort the page content depends on (alphabetically, newest to oldest and oldest to newest etc...)? I’d like another drop down tab on the left side ...
0
votes
0answers
18 views

Native admin table with search functionality: sorting by columns does not work

I display a WP_List_Table on a submenu_page and offer a search function, which works. However, if I sort by a column within a search result, all records are displayed again. I really don't know why ...
1
vote
0answers
32 views

How to sort by columns within a search result without displaying all rows again after sorting

I want to display a WP_List_Table on a submenu_page and offer a search function. The display of the data works so far and also the search, but the column sorting causes problems. If I click on the ...
0
votes
0answers
23 views

meta_query orderby sort multiple keys

I'm trying to read the birthdays of the users in my database through custom fields that have been added. Displaying the current months is easy but I am trying to capture the current month(remainder) ...
2
votes
1answer
32 views

How to sort posts with the first 2 or 3 by latest, and the rest is random?

I'm trying to sort my posts in the way I stated in the title. What's the simplest way to do this? I know how to change the order by object using the pre_get_post hook. But how can I use it to get ...
0
votes
0answers
49 views

WordPress Comments sort by custom meta key

I want to sort comments by a number of likes which is saved as a meta_key in the wp_commentmeta table: I have tried two ways but it doesn't sort the comments by most liked comment at the top. Please ...
3
votes
1answer
101 views

Sortable admin column for one meta key with three possible meta values

I've looked over 2 or 3 similar looking threads regarding sortable columns and the meta queries involved with making them work. None seem to resolve my exact problem. I am using the pre_get_posts ...
1
vote
0answers
27 views

Understanding the orderby in WP_Query?

For quite a while I have been trying to query posts, with 2 different meta_queries, and order them differently. I followed the WP codex. Recently I have found out that I have been mistaken this ...
0
votes
0answers
43 views

Order 2 meta_queries differently in WP_Query?

I have a custom WP_Query with 2 different meta queries. I want to order the results of both queries differently. The first meta_query I want to order by a custom field (high integer - low integer). ...
1
vote
1answer
29 views

Custom post type, organized by categories

I know there are lots of questions and answers out there for this very thing, but I'm having a hard time putting it all together. The goal is to get a <ul> with category names as the <li>, ...
0
votes
0answers
47 views

How to sort wordpress posts by distance and date

I want to sort wordpress posts by user's distance from posts location and by date by using some calculation..Here is the formula. 2*log(distance) - log(time in seconds) I saved post's latitude and ...
0
votes
0answers
31 views

How to use multiple orderby conditions on query search results? (orderby one post type, relevance)

I have a need to sort the search results so that a custom post type "authors" is always at the top, followed by all other post types sorted by relevance. I've found numerous examples about altering ...
0
votes
0answers
17 views

Need a Plugin for Sorting Specific Category Posts within a Static Page

I am NOT a strong PHP coder and mainly create sites using plugins and custom CSS which I am strong at. I have a page listing posts from a specific category. The page is built using Elementor Page ...
0
votes
0answers
203 views

woocommerce product sorting based on custom fields

I am trying to add a custom sorting option for woo commerce . So I am using following code to add new sort option plus set it as default meta key is '_am_cat_sort' function ...
0
votes
2answers
28 views

Sorting post by custom field and category

I want to sort posts by a meta value in a custom field. Basically I've added a field called 'date_event' and want to sort the posts by that date (stored as YYYYMMMDD). The only working example I have ...
0
votes
1answer
51 views

Wp Query sort order from custom MetaBox

I am trying to sort a list of post based of the meta_key deal amount, which would be to display the highest deal first and work its way down to smaller deal amounts. The deal amount would be anywhere ...
0
votes
2answers
55 views

Case insensitive ORDERBY in wpquery

I'm trying to sort custom posts in alphabetical order, and I've just now realized that capital letters are being sorted before lowercase. Two restaurants start with 'Cal' and 'CAT' with 'CAT' being ...
0
votes
2answers
165 views

Woocommerce Category Sort Dropdown

In Woocommerce Category page default sort dropdown has like below options. My question is what/how products sort by Popularity ? Not a code What is the measurement ? like if sort Price: Low to High,...
0
votes
1answer
156 views

Sort by last word in title

I need to order posts within a category alphabetically based on the last word in the title. I have seen a few suggestions online but none fit correctly. I am using a custom layout for the category ...
0
votes
0answers
55 views

Sort posts on custom field AND after that sort on date?

I'm having trouble to understand customizing the new WP_query. I've found the script below, partly, here in order to get the sticky posts. I've further edited it in order to: first get the (sticky) ...
0
votes
2answers
90 views

Orderby Title not working

When I'm trying to sort my blog posts or my woocommerce in alphabetical order nothing changes. If I access the /?orderby=title-asc or ?orderby=title-desc it brings me the same results. Any sugestions?...
0
votes
1answer
22 views

How to mix two orderby-parameters into one ordered result

I'm trying to figure out how to get an alphabetically ordered list of posts using two different orderby parameters. Im filtering the archive query something like this: function ...
0
votes
0answers
19 views

Custom Sort Order for looping through Taxonomy

I'm looping through all categories for a custom post type. What I'm trying to do is manually set the order for the loop by taxonomy id: My current format is: $categories = get_terms( '...
1
vote
1answer
192 views

WooCommerce sort products by the actual product width(not the shipping width)

I have regular/simple products and products with variance in the database. Regular products and variations have a product width(_pm_width_inches) associated with them . I am trying to sort based the ...
4
votes
4answers
1k views

WordPress post sorting with AJAX

I am having a search result page for custom post type. I want to have a ajax sorting feature. Eg sort the post by taxonomy without reloading the page. A very basic example will help. Thanks The ...
0
votes
0answers
209 views

Custom sort by menu_order not working when set as Default product sorting

I have products with Gallons as size so I want to list products in ascending order by Gallon size so I added numeric gallon values to the menu_order attribute field. After adding the below code to the ...
0
votes
2answers
763 views

how to get post order by post id wp_query?

i have 4 post and i displaying 2 post per page. $ids = array('16085','16088','16083','16091'); $options = array( 'post_type' => $post_type, 'posts_per_page' => $posts_per_page, ...
0
votes
1answer
256 views

Multiple sorting criteries (order by)

I want my products to be sorted by price (ascending) and products, which are out of stock be placed at the end of the products list. How can I achive this in WooCommerce? Is it ever possible to ...
0
votes
1answer
65 views

change order of images attached to post

Im not quite sure how to explain my issue so let me know if Im unclear about anything. I have on my front-end post form a multiple file upload input that uploads files to my specified folder and ...
0
votes
0answers
35 views

WP_Query order_by custom meta with advanced query

So I am trying to WP_Query all post type of "triextras" There are 2 types of "triextras" categorised by taxonomy: news (id:22) and events (id:21) Events has custom field event_date. When I query ...
0
votes
0answers
296 views

Column sorting for taxonomy table using Advanced Custom Fields

I'm trying to get my admin columns on edit-tags.php to be sortable by ACF field value, but I'm missing something. I can click the column heading to sort the column, but it only sorts the table by tag ...
0
votes
0answers
21 views

How to sort posts by 1-5 star rating selected by the user?

How to get than after a user clicks 5 stars I get that info and use it to sort posts who have a 5 star rating. <form action=""> <img class="ylli-1" src="img/icons8-christmas-star.svg" alt=""&...
0
votes
1answer
23 views

sort items by randomness

I have an e-commerce shop. I am new to php and wordpress. (I have a python and ruby background though, I just don't know php) And I have a page with items. Right now the last 20 items are displayed ...
0
votes
0answers
22 views

Problem with displaying products

I've got problem with my WC store. When I go in unregistered mode to category page, there are display just a few product (sorted by popularity). When I change sorting, after that are displayed all ...
0
votes
0answers
100 views

WP_query sorting can't sort danish letters (æ, ø, å)

I am having an issue, with making a WP query sort correctly, using danish special letters (æ, ø and å in this case). I have a loop running a query for certain post types, then returning them ...
0
votes
0answers
83 views

How to sort custom posts including null meta-values ​in admin columns with meta_query?

SQL REQUEST SELECT post.ID, month.meta_value, year.meta_value FROM wp_posts post LEFT OUTER JOIN wp_postmeta month ON month.post_id= post.ID AND month.meta_key='mcv_end_month' LEFT OUTER JOIN ...
-1
votes
0answers
23 views

sort by custom field in taxonomy page

I want to sort posts by a custom field and applied following code. It works on the archive pages, but it doesn't work on the taxonomy pages. The codes for archive and taxonomy are same, i.e., "archive-...
0
votes
1answer
42 views

Using Orderby and meta_value to order natural/alphanumerical

I added a custom column for a custom post type. Then I put it to be the 3th column, and now I want to sort it alphanumerical. I use this action : add_action( 'pre_get_posts', '...
0
votes
0answers
30 views

Ajax sorting not show correct result?

i am working my website . when i am trying to sort the listings using sort options it is not showing correctly. i am attaching the following image in which i mention that if i select sale & rental ...