Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to change the post order?


  • viniciusrsb
    Participant

    @viniciusrsb

    Hi Everyone,

    I’d like to know if you guys know how to change the post order, my client wants to see the last message at the first place…. is it possible?

    For example:

    Message 5
    Message 4
    Message 3
    Message 2
    Message 1

    Thanks,

    Vini

Viewing 3 replies - 1 through 3 (of 3 total)

  • Robkk
    Moderator

    @robkk

    add this to your child theme functions.php or install the plugin below.

    function bbp_reverse_reply_order( $query = array() ) {
        $query['order']='DESC';
        return $query;
    }
    add_fiter('bbp_has_replies_query','bbp_reverse_reply_order');

    https://wordpress.org/plugins/bbpress-sort-topic-replies/


    Wilfrank
    Participant

    @wilfrank

    I made a small change so that the user can choose the sort order, but can anyone tell me why it does not work?

    function custom_bbp_has_topics($order) {
    
      switch ($order) {
        case 1:
            $args['order'] = 'ASC';
            break;
        case 2:
            $args['order'] = 'DESC';
            break;
        default:
            $args['order'] = 'DESC';
      }
      
      return $args;
    }
    add_filter('bbp_before_has_topics_parse_args', 'custom_bbp_has_topics' );

    Robin W
    Moderator

    @robin-w

    you’re filtering a different function

    Robkk is filtering ‘bbp_has_replies_query’

    at worst you should be filtering

    ‘bbp_before_has_replies_parse_args’

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar