Tagged: sorting
- This topic has 3 replies, 2 voices, and was last updated 2 years, 2 months ago by Theme Horse Support Team.
-
AuthorPosts
-
January 2, 2022 at 8:09 pm #95844M SrinivasParticipant
Much appreciate it if some creative ideas are provided to show the posts sorted by alphabetic sequence/sorting. I realize that WordPress by defaults sorts it by date uploaded, I found a script which I was able to put in functions.php to sort by A-Z. I can see this change when I see the lists of posts in the category and it works well. Unfortunately, TH: Horizontal/Vertical and TH: Card/Block still shows posts by their uploaded date. For the type of content I’m inserting in posts, it is key that I show the posts in their alphabetic sequence.
January 4, 2022 at 10:06 pm #95922Theme Horse Support TeamKeymasterHi M Srinivas,
You also need to Customize the Code for Widgets as well. You can find the Widgets php files on ‘inc > newscard-widgets.php’.
Thanks
February 2, 2022 at 3:29 pm #96702M SrinivasParticipantThank you. Are you indicating that I can change sort order of TH: horizontal/vertical and TH: card/block by editing newscard-widgets.php?
In functions.php I am using this code to change the sort order of posts. I need to change the sort order of the display of the TH blocks as well.
//ADDED THIS FUNCTION (LINES 27 TO 38) FOR CUSTOM SORTING BY TITLE NAME
function order_posts_by_title( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query-set( 'orderby', 'title' ); $query-set( 'order', 'ASC' ); } } add_action( 'pre_get_posts', 'order_posts_by_title' );
February 20, 2022 at 1:58 am #97154Theme Horse Support TeamKeymasterHi
Yes, you need to add the same code on the “TH: Card/Block Posts” and “TH: Horizontal/Vertical Post” widget code as well.
Thanks
-
AuthorPosts
- You must be logged in to reply to this topic.