-
AuthorPosts
-
September 18, 2024 at 9:04 pm #1467361
Hi,
I would like to sort my custom posts oldest to newest.
I have tried various plugins that promise to let you choose to sort categories ascending versus descending but none seen to work.
I wonder if this is because of the way I am putting out my thumbnails with this custom code:Is there a way I can switch to oldest to newest sort order?
ThanksSeptember 19, 2024 at 7:14 am #1467423Hey lucybb2,
Thank you for the inquiry.
There is no option for this by default but you can use this filter in the functions.php file to adjust the sorting of the blog posts in the grid.
add_filter('avia_post_slide_query', 'avia_post_slide_query_mod'); function avia_post_slide_query_mod($query) { $query['orderby'] = 'date'; $query['order'] = 'DESC'; return $query; }
Best regards,
IsmaelSeptember 19, 2024 at 7:45 pm #1467480This code didn’t work for me. There was no error. Just no change.
Thanks for trying.
LucySeptember 20, 2024 at 5:01 am #1467503Hi,
Thank you for the update.
Where did you place the blog posts element? Please provide a direct link so we can check it. Also, try replacing the order value from DESC to ASC. Let us know the result.
Best regards,
IsmaelSeptember 20, 2024 at 12:05 pm #1467524Thanks.
It is this page: https://guardingtheguards.com/category/journals/constabulary-gazette/
In my functions I have this code putting it out.
add_filter(“avf_post_slider_args”, function($atts, $context) {
if ($context == “archive”) {
$atts[‘type’] = ‘grid’;
$atts[‘columns’] = 5;
$atts[‘preview_mode’] = ‘custom’;
$atts[‘image_size’] = ‘thumbnail’;
}
return $atts;
}, 10, 2);When I added the code you gave me here to functions, it did nothing. No error, but no change.
When I change to ASC the order does change but it makes no sense, it sort of seem to randomise the order.
I note I am trying to order by post date and my post dates start in the 1970s and got up to the present.
Thanks
Lucy
September 23, 2024 at 5:36 am #1467632Hi,
Are you trying to sort the posts based on the date in their title, e.g., “Constabulary Gazette, Jun 1980”? Please note that the filter will sort the posts based on their publication date. Unfortunately, there is no option to sort posts based on text in the title.
Best regards,
IsmaelSeptember 23, 2024 at 10:32 am #1467648No, I am trying to sort on their publication date (which is each case I have manually set to the title date).
There are lots of plugins that offer to do this, e.g.
But they don’t work for me so I can only guess that is because of way I am putting out the thumbnails for Enfold?
Thanks
September 24, 2024 at 6:56 am #1467713Hi,
Thank you for the info.
It seems that the sorting is not working due to the custom query in the archive.php template. We’ll get back to you once we find a suitable modification.
Best regards,
IsmaelOctober 20, 2024 at 10:04 pm #1469517I was trying to figure this out as well. Was a suitable modification found?
October 21, 2024 at 5:24 am #1469526 -
AuthorPosts
- You must be logged in to reply to this topic.