Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reversing order of topic, BUT leaving the original topic at the top..


  • grex22
    Participant

    @grex22

    We’ve had a request to reorder the way a topic’s page displays, such that the original topic post would be at top, but then the subsequent replies would be below that post in newest->oldest order.

    I’ve seen snippets that filter bbp_has_replies_query() and change the ‘order’ parameter, and this works nicely for getting the order to newest->oldest. However, it ALSO throws the original topic at the very bottom of the order. We want the topic post first.

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • So close… Indeed you use bbp_has_replies to reverse order the replies

    function custom_bbp_has_replies() {
      $args['order'] = 'DESC'; // 'ASC' (Ascending, Default), 'DESC' (Descending)
      
      return $args;
    }
     
    add_filter('bbp_before_has_replies_parse_args', 'custom_bbp_has_replies' );

    And use bbp_show_lead_topic to always show the ‘lead topic’ (More details here.

    function custom_bbp_show_lead_topic( $show_lead ) {
      $show_lead[] = 'true';
      return $show_lead;
    }
     
    add_filter('bbp_show_lead_topic', 'custom_bbp_show_lead_topic' );

    grex22
    Participant

    @grex22

    Perfect — this worked like a charm. Thanks so much for your help!


    undsatca
    Participant

    @undsatca

    I am currently trying do the same thing, set newest to oldest with the original topic post remaining on the top.
    I am a novice with code and CSS, and was curious where the code you provided for grex22 went. I am familiar with the .php location of bbpress, but can not find the information you posted.

    Thank you


    czentnar
    Participant

    @czentnar

    function custom_bbp_has_replies() {
    $args[‘order’] = ‘DESC’; // ‘ASC’ (Ascending, Default), ‘DESC’ (Descending)
    return $args;
    }
    add_filter(‘bbp_before_has_replies_parse_args’, ‘custom_bbp_has_replies’ );

    Thank you for the great solution, @netweb!
    However, as I changed the query, the post IDs got messed up (this appears when I click on the ID starting with “#” in the top right corner of the post). Also, after submitting a new post, bbPress jumps to the last page in that topic, despite the fact that the order has already been changed and the latest reply is on the first page (this could be a result of the messed ID’s, I think).

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