Skip to main content

All Questions

Tagged with
7 votes
4 answers
3k views

Random sort within an already sorted query

I have a working query which returns a set of custom posts which are ordered by their package ID (ASC). For a query with 9 results this may return for example: 4 posts (Post ID's 1,2,3,4) with ...
David Clough's user avatar
6 votes
2 answers
3k views

Sort custom post type list table by display name of a user id stored as post meta value

I have a custom post type named domicile. Each post (domicile) has an owner (not the author). Owners are users with a custom role. I store the user id as a post meta value (dmb_owner) for the domicile ...
fuxia's user avatar
  • 107k
5 votes
4 answers
29k views

Sort posts by category name and title

Trying to figure out how I can output my posts based on category title (a–z) and secondly, the title of the posts within the category: A CATEGORY – A post beginning with a – Because I want to be ...
INT's user avatar
  • 1,281
3 votes
2 answers
746 views

Sort X categories by last update and show image

I want to display X categories, and sort them by last update. I also want to grab the image of the latest post with the category. <img src="<?php echo get_image('article_image',1,1,0,NULL,$...
Martin-Al's user avatar
  • 844
3 votes
3 answers
2k views

Fulltext search in posts sorted by relevancy

I'm building a custom search page and what I need is to sort results by relevancy (eg. occurences of a keyword) Using MySQL docs I've built this query: SELECT ID FROM $wpdb->posts WHERE MATCH (...
Smaug's user avatar
  • 151
2 votes
3 answers
2k views

Sorting Grids with Essential Grid and Events Manger

I am using Events Manager to control my Events, but Essential Grids to display previews of these events in various places throughout my site. An example of this is http://staging-dbmax....
Grant Smith's user avatar
2 votes
1 answer
3k views

Query Set Order By Author

I am attempting to orderby the author_name when you click on the Author arrow on a list of tickets. When you click the arrow, the names are ordering by something I cannot identify. I want them to ...
ILikeTurtles's user avatar
2 votes
0 answers
78 views

Sorting posts alphabetical that have single digits

I have post titles that are like this: Episode 1 Episode 2 Episode 6 Episode 10 Episode 14 I try to list posts alphabetically but it ends up showing like this: Episode 1 Episode 10 Episode 14 ...
Ruriko's user avatar
  • 543
1 vote
1 answer
6k views

Sorting posts according to view counts not working

I use the code snippet below to get views count of each post on my sidebar.php . everything works but the sorting does not. also it does not get 4 posts, it only shows 1 post although I've written '...
Payam Shakibafar's user avatar
1 vote
4 answers
5k views

sort search results by custom fields using dropdown

On my search.php page, I have a "Sort By" dropdown that almost works exactly how I want it to -- <select class="dropdown-class" name="sort-posts" id="sortbox" onchange="document.location.href=...
730wavy's user avatar
  • 193
1 vote
2 answers
1k views

How to orderby meta_value_num with dollar ($) sign

The custom fields all have prices including $ signs, and a dot as separator. $theQuery = new WP_Query(array( 'orderby' => 'meta_value_num', 'meta_key' => 'price', 'order' => ASC )); All ...
coder's user avatar
  • 45
1 vote
1 answer
29 views

Order By Post Type ThenBy Taxonomy

Assuming I have these custom post types: Product Video Article And for Product (WooCommerce Product), we have many Categories, one of which is called "Parts". I have this situation where I ...
wooncherk's user avatar
  • 111
1 vote
1 answer
142 views

query loop "inherit query from template" prevents setting sort order

I need all auto-generated category pages to sort oldest-to-newest I'm editing my "All Archives" template in block editor but I'm not having any success it contains a query loop with "...
Displayname71's user avatar
1 vote
0 answers
419 views

Compare ACF date field (if exists) and post date and order DESC

I have an ACF date field (same format as post date) and in my Query I want it to be compared to the publish date of the post: If erstelldatum is not empty use erstelldatum for order If erstelldatum ...
Omitheus's user avatar
1 vote
0 answers
533 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 ...
Martin's user avatar
  • 21

15 30 50 per page