Skip to:
Content
Pages
Categories
Search
Top
Bottom

Single reply redirect to topic

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

  • Vinod Dalvi
    Participant

    @vinod-dalvi

    @angelorocha Not sure exactly what you are trying to achieve here so could you please describe it a bit more in detail by sharing screenshot or page URL of it?


    Angelo Rocha
    Participant

    @angelorocha

    Hi Vinod.

    In search results, when the result is a “reply” post type, the link show only a reply.
    I want click in the reply and this redirect to parent topic. Sorry for my bad english, i’m from Brazil =)


    Vinod Dalvi
    Participant

    @vinod-dalvi

    Actually you have to click on the topic title as shown in the screenshot here http://imgur.com/a/T5aNz to go to the topic where the reply is posted.


    Angelo Rocha
    Participant

    @angelorocha

    Hi, Vinod Dalvi. Sorry for delay.

    Actually, when click in link for single reply in search results, the single reply don’t show the parent topic in single reply template, i want redirect single reply template to topic parent.


    M C
    Participant

    @mcyger

    I’d like to know the answer to this question too.

    @angelorocha, did you ever find a solution?


    kdelsimone
    Participant

    @kdelsimone

    Same problem here. I’m looking for a way to redirect the reply post (for me it’s listed via a widget) to the topic where the reply was created. Currently it redirects to another page showing only the reply post, not to the topic page where the reply was originally created. Any suggestions?


    Angelo Rocha
    Participant

    @angelorocha

    No solution for this problem yet =(


    kdelsimone
    Participant

    @kdelsimone

    OK, still trying to figure this one out…

    From what I can tell, the problem we are encountering is that the URL is defined as:

    https://site.com/forums/reply/12345

    when it needs to be:

    https://site.com/forums/topic/[topic_title]/#post-12345

    In the first case, the redirect goes to the single reply post. In the second, the redirect goes to the post within the topic thread, which is what I believe we are each trying to achieve here.

    Also, it seems to work correctly in the bbpress Recent Replies widget — meaning the widget utilizes the URL in the second case (above) and redirects correctly to the parent forum/topic. I’ve looked through the widgets.php file but can’t figure out where it’s pulling the reply_url from and why it’s different from the reply post permalink.

    Does anyone know where the permalinks or URLs for the reply custom post type are defined in the bbpress plugin files? Perhaps that could be a place to start…

    And, any suggestions or assistance would be appreciated!


    Robin W
    Moderator

    @robin-w

    bbpress with a default theme (eg twentseventeen) will do the following

    • search for say ‘hello’
    • bbpress will produce all single topics and single replies that match this (which could be many)
    • for a reply you will see the reply with the words In reply to :the topic name as a link
    • click the topic name and you are taken to the topic

    If this is not what you are getting, then come back


    brent0r
    Participant

    @brent0r

    You can also go directly to the reply by clicking the post #number on the top right of each result.
    Are you wanting to change your search results so that “In reply to: Topic Title” redirects to the #post within that topic?


    kdelsimone
    Participant

    @kdelsimone

    Thanks, @robin-w & @brent0r, for your responses.

    Using search, I get exactly as @robin-w describes, which makes sense and is not a problem (for me, at least). The problem I am encountering is that third-party themes and plugins that use the bbpress reply post type redirect to the single reply post as opposed to the post in the topic thread. That is, they go to the reply/number ULR instead of the topic_title/#post-number URL. I’m aware, as @brent0r suggests, that clicking on the post #number in the top right takes the user to the topic_title/#post-number, but unfortunately this isn’t intuitive for my users and it is negatively impacting engagement in my community.

    I notice that the bbpress Recent Replies widget redirects users to /#post-number, which is what I am trying to accomplish. I just can’t seem to figure out where that slug is defined, as it is apparently not the same as the bbpress reply post type. I’m assuming I could modify the plugin’s files to behave similarly if I could figure out where to tell it to pull the ULR from.

    I wonder, too, if perhaps I should have started a separate thread. I thought the issue I had was the same as @angelorocha, the OP, but perhaps we’re encountering different problems…? My apologies if I’ve hijacked the thread with a different issue. I’m hoping the solution(s) will be the same…

    Thanks again for your help. I appreciate this community.


    brent0r
    Participant

    @brent0r

    @kdelsimone
    If you want the link changed from the topic to the reply, I suggest copying loop-search-reply.php from /wp-content/plugins/bbpress/templates/default/bbpress to your child themes bbpress directory @ /wp-content/themes/theme-child/bbpress
    From there you can edit it and change line 25 from this:
    <a class="bbp-topic-permalink" href="<?php bbp_topic_permalink( bbp_get_reply_topic_id() ); ?>"><?php bbp_topic_title( bbp_get_reply_topic_id() ); ?></a></h3>

    to this:
    <a class="bbp-topic-permalink" href="<?php bbp_reply_url(); ?>"><?php bbp_topic_title( bbp_get_reply_topic_id() ); ?></a></h3>


    James Revillini
    Participant

    @jrevillini

    I coded something you can add to your functions.php file which will do this.

    // ---------------------------------------- REDIRECT REPLY POSTS TO TOPIC WITH REPLY ANCHOR
    function jrevillini_reply_redirect( $wp_query ) {
      if ( !function_exists('bbp_get_reply_url') ) return;
      if ( !isset($wp_query->query['reply']) ) return;
      wp_safe_redirect( bbp_get_reply_url( $wp_query->query['reply'] ) );
    }
    add_action('pre_get_posts', 'jrevillini_reply_redirect');
    

    James Revillini
    Participant

    @jrevillini

    BONUS: smooth scroll to the anchor point when page loads with this plugin: https://wordpress.org/plugins/page-scroll-to-id/


    kdelsimone
    Participant

    @kdelsimone

    @jrevillini Bless you!! This is exactly what I was looking for, and the BONUS smooth scroll is a bonus indeed–Thank you!!!

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