Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reverse order replies and pagination


  • webmasterfreya
    Participant

    @webmasterfreya

    Hi,

    I have the following code in my themes functions.php
    function bbp_reverse_reply_order( $query = array() ) { // bbp_has_replies_query is depricated ?
    $query['order']='DESC';
    return $query;
    }
    add_filter('bbp_has_replies_query','bbp_reverse_reply_order');

    This works fine except when a new reply is added, you get redirected to the page with the oldest replies instead of the page that contains the just added reply. This seems to be an old problem, have tried various plugins, but they all lead to the same outcome.

    So the question is how to force, after adding a new reply, to be directed to the right page.

    site freya.nl, latest versions WordPress and bbPress.

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

  • webmasterfreya
    Participant

    @webmasterfreya

    No replies for 17 months 🙁

    Some thoughts:

    Also the notification emails contain a wrong link (highest page number instead of first)

    Sends notification emails for new replies to subscribed topics
    \wp-content\plugins\bbpress\includes\common\functions.php

    1061 function bbp_notify_topic_subscribers

    1101 $reply_url = bbp_get_reply_url( $reply_id );

    if the order =’DESC’ for replies maybe then use bbp_get_topic_permalink as $reply_url ?

    As mentioned above after adding a new reply to a topic one should also be redirected to the first page (bbp_get_topic_permalink ?)

    Probably there are some more places where the same should apply.


    Back to Front
    Participant

    @traverser11

    Checking in because I want this too… there was a plugin called ‘bbpress sort topic replies’, that no longer works, but I’m going to try to grab the code from that


    Back to Front
    Participant

    @traverser11

    I gave it a go, and it kinda worked, lol…
    But this reverses all the replies INCLUDING the original topic.
    So the original topic goes to the bottom…
    What I would ideally want is the Topic, THEN the replies in reverse order…

    // Reverse reply order on News topic
    
    add_filter('bbp_has_replies_query','bbp_reverse_reply_order');
    function bbp_reverse_reply_order( $query = array() ) {
    	// Identify post type
    	$bbPress_post_id = get_the_ID();
    	$bbPress_post_type = get_post_type($bbPress_post_id);
    
    	if( $bbPress_post_type =='topic' ){
    
    		/** TOPIC **/
    			$query['order']='DESC';
    			return $query;
    
      }
    };

    Robin W
    Moderator

    @robin-w


    webmasterfreya
    Participant

    @webmasterfreya

    Thanks for your work ‘Back to Front’.

    Did you also test for the right links to the right page (so when having multiple pages of replies, after adding a new reply one should end up at the first page not the last?


    Back to Front
    Participant

    @traverser11

    Thanks again @robin-w and @webmasterfreya

    I ended up deleting the part causing errors from ‘bbpress sort topic replies’ plugin, and that works – (for topics not for forums though)… Its nice because it gives the ‘show lead topic’ and reply sort order in the admin meta box. Can share somewhere if its useful.

    But yes now I see what you mean! that upon posting the newest reply, it redirects to the last page of the pagination, which in the case of replies descending by date, makes no sense. Sorry for hijacking your topic!

    Hmmm any ideas where to start on this?


    Back to Front
    Participant

    @traverser11

    Oh here is an answer!

    Wrong bbp_get_reply_url() when paging with reverse order

    This snippet works – i’m just a bit confused how to turn it on when replies are descending and off when they are ascending…

    add_filter('bbp_get_reply_position', 'lugpa_get_reply_position', 10, 3);
    function lugpa_get_reply_position($reply_position, $reply_id, $topic_id){
        
        if(empty($topic_id))
            $topic_id = bbp_get_reply_topic_id ($reply_id);
        
        $numReplies = bbp_get_topic_reply_count($topic_id);
        return ($numReplies+1) - $reply_position; // plus one because of thread description
    }

    Robin W
    Moderator

    @robin-w

    @traverser11 – great that you are posting the answers here – so many don’t 🙂 🙂 🙂

    can you summarise where you are at, so eg

    use this plugin (are you still using the sort topic replies plugin?)
    delete this code from it
    add this code to this place

    etc.

    so it is all in one thread, I’ll then try to give to some switch on and off code


    webmasterfreya
    Participant

    @webmasterfreya

    Works! It seems to me that this works for both ASC and DESC sort.


    webmasterfreya
    Participant

    @webmasterfreya

    Hi,

    Your piece of code has an unwanted side effect. When looking at a subscriber as admin the created replies of this subscriber do not show anymore.
    I reverted back to the original code (on top of this topic) and presto the replies of the subscriber show up again.


    Back to Front
    Participant

    @traverser11

    I’m confused about which archive you are looking at that causes this problem?
    Sorry I got busy with my other jobs but I’ll come back to this, lets get it sorted!


    webmasterfreya
    Participant

    @webmasterfreya

    Hi Back to Front,

    I also have buddypress installed. As admin you have for each member a page wich among other things shows topics started and replies made by the member. The replies did not show up (and there were definitly replies).

    As buddypress makes use of bbpress for fora i expected your code to work but it did not (is the culprit then buddypress or bbpress or your code? I haven’t the faintest idea).

    Maybe : if( $bbPress_post_type ==’topic’ ){

    /** TOPIC **/
    $query[‘order’]=’DESC’;
    return $query;

    should have an } else {return $query}

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