Stack Exchange Network

Stack Exchange network consists of 174 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.

0
votes
0answers
8 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
11 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
21 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
22 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
32 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
37 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
50 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
21 views

WPquery mulitple sort orderby

I have a post_type with multiple dates and would like to sort it a certain way - but after way too long on this simple task, I'm still stuck :) How I want it to sort: Every post with a Date2 set, ...
0
votes
0answers
26 views

WP_Query sort posts with deadlines

We build our own CRM in WordPress and created a custom field for deadline (date). When we query this out, we want to sort these by the date and if no date is set, put that in the end. Is this ...
0
votes
0answers
30 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
29 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
20 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
13 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( '...
0
votes
0answers
24 views

Sort Custom Column in Admin Users Panel

I have added a new column in admin Users Panel that shows the last date when an user has submitted a post. Everything is working well but now I just need to make it get sortable and I am a bit stuck ...
1
vote
1answer
106 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
382 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
133 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
160 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
164 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
0answers
77 views

Sort admin column based on an acf within a post object

I have a question about sorting admin columns based on an acf, and the 'post_title' within within a post object. I am following this set up here - https://www.ractoon.com/2016/11/wordpress-custom-...
0
votes
1answer
61 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
32 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
179 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
16 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
22 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
65 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
51 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 ...
0
votes
0answers
18 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
26 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
25 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 ...
0
votes
0answers
32 views

Sort by custom field in archive.php with Ajax

how can I sort custom post types by custom field value with ajax. There should be options "Newest" and "Oldest".
0
votes
0answers
28 views

How to order blog posts by no. of likes?

I am using a plugin called Kodex likes and it has a counter for how many likes a blog post got. If I add sorting parameters to the URL using the ones already built in Wordpress like: www.website.com/...
0
votes
0answers
43 views

Sort by Featured products, shows some which are not

I’ve added the code below to my functions.php to make it possible to ‘sort by featured’. Although, some items do show up which are not marked as featured. I can’t figure out why the keep showing op ...
0
votes
0answers
45 views

Order posts by specific post IDs

I have the following code: $viewed_products = [3358, 3296, 3929, 3368]; $query_args = array( 'posts_per_page' => 4, 'no_found_rows' => 1, 'post_status' => 'publish', '...
1
vote
0answers
25 views

WP Query sort by meta value

I would like to get posts order by timestamps. I have to following code but the query keeps getting posts order by modification dates and not with the "evcal_srow" meta. Any clue? <ul class="...
0
votes
0answers
170 views

Sort order using get_the_terms() for multiple taxonomies

I'm using get_the_terms() to echo the term names of multiple taxonomies by passing an array of taxonomy slugs, as follows: $terms = get_the_terms( get_the_ID(), array('tax-1-slug', 'tax-2-slug') ); ...
4
votes
1answer
119 views

How to Arrange Posts by Size in the WordPress Dashboard?

This may be a lame question, but I can't find an answer to this. Let's say you have a ton of empty posts that you want to delete. Obviously those who have some content will have more size. Is there ...
0
votes
1answer
796 views

Custom post type sorting: alphabetical order

I want to display my custom post type "portfolio" in alphabetical order and I got it working fine with this code: add_filter("posts_orderby", "my_orderby_filter", 10, 2); function my_orderby_filter($...
0
votes
1answer
900 views

Sorting search results with custom dropdown

I have the following select dropdown code for sorting on my search results page (search.php) that works for custom fields. <div id="sortby"> SORT BY: &nbsp; <select class="dropdown-...
0
votes
1answer
17 views

Sort posts by clicks on download button

In my website each post has a download button for a certain asset. I want to be able to sort my posts by how many times an asset has been downloaded (or, in other words, how many times the download ...
0
votes
0answers
20 views

sort options for search results

I have a search for specific categories posts, the category is called archive, and am wondering if after they are displayed they can be sorted by either most recent or most relevant via a dropdown. ...
0
votes
0answers
23 views

How sort posts by average daily vews?

I'm creating a plugin that inserts a widget in the sidebar, it sorts the posts by comments, total views and average daily views, For the count views i do with this functions: //get posts views ...
0
votes
1answer
23 views

sorting in wp query based on custom field value

I am trying to get posts of custom post type 'job_listing' on bases of two custom fields i.e 1) _job_location 2) _company_name this is working fine but I also want to display the posts first that ...
0
votes
1answer
593 views

Order woocommerce products alphabetically by second word in title?

My site actually has people's names as product titles and I really need it to sort alphabetically by the second name (surname) I think I've found solutions to enable this with default WP post titles ...
2
votes
2answers
264 views

Make custom column sortable

I have added custom column to a custom post type, and it works fine. I just want it to sore the names by title so tried this, function sortable_custom_columns( $columns ) { $columns['...
0
votes
2answers
547 views

How to sort (orderby) a query done by a template function before the 'foreach' loop?

How can I sort an array of elements being hold on a query done by a template function, just before the output starts on a foreach loop? I wanted to order my elements by the Post Title. Here is my code:...
0
votes
0answers
25 views

week days sorting based on starting day

I have a taxonomy with weekdays. I want them sorted based on basis of starting day opted by the user. Basically, I am working on Timetable and different regions have different starting day of week. ...
0
votes
1answer
271 views

inner foreach loop sorting

I have the following script and i need to sort the inner foreach loop alphabetically but with no success. $args = array( 'post_type' => 'clinical_sites', 'tax_query' => array( ...
1
vote
1answer
52 views

list posts and wrap them alphabetically A-Z

0 down vote favorite I have a list of posts on my website, what I'm trying to do is to wrap them alphabetically from A-Z by title to get a glossary like this : A. Apple B. Banana C. Carotts D. E....