Skip to:
Content

Opened 6 years ago

Last modified 3 years ago

#1962 new defect

BBpress does not get the right reply url if you change replies loop args.

Reported by: villagora Owned by:
Milestone: Future Release Priority: normal
Severity: major Version: 2.1.2
Component: Tools - Code Improvements Keywords: needs-patch
Cc: contact@…

Description

Hi,

I've modify the replies loop args for display last reply first ('orderby' => 'date', 'order' => 'DSC'); But if I post a new reply, BBpress redirect to the reply URL get by bbp_get_reply_url() function without paying attention to the order defined in the loop. So BBpress get the wrong page for my new reply (the last, instead of the first) and I'm redirect to the last page without my new reply.

That's a huge problem because, some one can reorder the replies by another value, by a metavalue for exemple. so the page returned must be calculated according to the display loop used.

NB : There are perhaps the same mistake for topics.

I hope you can implement that quickly. Thanks in avance...

Change History (6)

#1 in reply to: ↑ description ; follow-up: @alexvorn2
6 years ago

do you mean using query_posts() ?

#2 in reply to: ↑ 1 ; follow-up: @villagora
6 years ago

Replying to alexvorn2:

do you mean using query_posts() ?

No, I pass args directly to bbp_has_replies function in my custom bbpress theme compat ! ;)
But it's the same thing if you hook bbp_has_replies filter for make your own query...

#3 in reply to: ↑ 2 ; follow-up: @alexvorn2
6 years ago

Replying to villagora:

Replying to alexvorn2:

do you mean using query_posts() ?

No, I pass args directly to bbp_has_replies function in my custom bbpress theme compat ! ;)
But it's the same thing if you hook bbp_has_replies filter for make your own query...

I see... Do you have an idea how to fix it?

#4 in reply to: ↑ 3 @villagora
6 years ago

This quick and dirty solution seems to make the trick (copy/paste line 355 in bbp-reply-template.php):

I need to replace bbp_get_reply_position by another function like bbp_get_loop_reply_position. for this stuff, indeed, I can use query_posts() and count manually the new reply position ($reply_id here) :

//get the user query 
global $query_string;
                
// The Query
query_posts( $query_string );
$position = 1;

// The Loop
while ( have_posts() ) : the_post();
if (get_the_ID()==$reply_id)
  break;
else
  $position++;
endwhile;

// Reset Query
wp_reset_query();

$reply_page = ceil( (int) $position / (int) bbp_get_replies_per_page() );

That works, but I don't know how we could do without this extra loop ..?

#5 @johnjamesjacoby
6 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Priority changed from high to normal

The solution above is pretty bad. Even so, this needs to get bumped to future release.

For now, the return values of bbp_get_reply_url() and bbp_get_reply_position() can be filtered if you need to customize them.

#6 @Chaton666
3 years ago

  • Keywords needs-patch added

Hi,
I have the same problem here with the bbp_topic_freshness_link() function (loop-single-topic.php), is there any solution since the first ticket ?
Thanks,
Marie.

Note: See TracTickets for help on using tickets.