Back to Front (@traverser11)

Forum Replies Created

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

  • 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!


    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
    }

    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

    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;
    
      }
    };

    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

    Thanks again for taking a look is the code that appends the checkboxes to the bbpress topic forms… I guess $_POST is a global variable that bbpress topic form is also using?

    Sorry this is obviously a bit beyond me. And obviously beyond a free solution! But yes if you or others in bbpress do paid work like thiset me know and I’ll be in touch!

    // Add custom taxonomies to topic form
    
    add_action ( 'bbp_theme_after_topic_form_content', 'bbp_extra_fields');
    
    function bbp_extra_fields() {
    
    $value = get_post_meta( bbp_get_topic_id(), 'issue', true);
    	echo '<div id="custom-meta">';
    	echo'<fieldset>
            <legend>Issues</legend>';
    	$issues = get_terms('issue', array('hide_empty' => 0));
    	foreach ($issues as $issue) {
    	echo '<span><input type="checkbox" class="issue" for="issue" value="'.$issue->slug.'"></input><label>'.$issue->name.'</label></span>';
    	};
    	echo '</fieldset>';
    
    $value = get_post_meta( bbp_get_topic_id(), 'region', true);
    global $region;
    $region = get_terms('region', array('hide_empty' => 0));
    echo'<fieldset>
            <legend>Region</legend>';
    $regions = get_terms('region', array('hide_empty' => 0));
    foreach ($regions as $region) {
    echo '<span><input type="checkbox" class="issue" for="issue"value="'.$region->slug.'"><label>'.$region->name.'</label></span>';
    };
    echo '</fieldset></div>';
    };

    Back to Front
    Participant

    @traverser11

    Thanks @robin-w! I’m still very lost, but I’ll try and pick up the clues from this as best I can:
    using bbp_new_topic_post_extras() in place of bbp_new_topic() ?
    using wp_update_post() instead of wp_set_object_terms() ?

    And I guess these two functions define $terms and all the variables seperately within each… I think that’s the bit I”m most confused how to achieve…

    Hmm I’ll keep trying, but launch the site first and leave this feature for down the track.
    but if anyone knows how to work this out, and wants some work to do it, let me know 🙂


    Back to Front
    Participant

    @traverser11

    I was having a bunch of trouble with this too, 8 years later!

    I tried
    bbp_topic_excerpt('200')
    and
    wp_trim_words( bbp_topic_excerpt(), 200, '...' );
    But they wouldn’t actually change the excerpt length.

    Anyway I found this other function in bbpress files, that does the job.
    bbp_get_topic_excerpt($topic_id = 0, $length=200)


    Back to Front
    Participant

    @traverser11

    Oh I found the error in my code above
    Just replacing
    is_category()
    with
    is_archive()

    Still, not sure I’m taking the best approach here,
    maybe I’m missing a simpler way to categorise topics?

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