badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

TH: Horizontal/Vertical Post and TH: Card/Block Posts

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #95844
    M Srinivas
    Participant

    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.

    #95922

    Hi 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

    #96702
    M Srinivas
    Participant

    Thank 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' );
    #97154

    Hi

    Yes, you need to add the same code on the “TH: Card/Block Posts” and “TH: Horizontal/Vertical Post” widget code as well.

    Thanks

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.