Skip to:
Content
Pages
Categories
Search
Top
Bottom

Specific Forum Topic Not Arranging


  • BekBek20
    Participant

    @bekbek20

    Hello everyone.

    I have been issues with sorting my BBpress forum topic on the front end.

    So i tried to use a custom function i got from one of the threads.

    Here is the code i used.

    //* Change sort order of Topics within a specified bbpress forum
    function my_custom_display_topic_index_query ($args) {
    $thisforumid = bbp_get_forum_id();

    if($thisforumid == 43135) {
    $args[‘orderby’] = ‘date’;
    $args[‘order’] = ‘ASC’;
    }

    return $args;
    }
    add_filter(‘bbp_before_has_topics_parse_args’, ‘my_custom_display_topic_index_query ‘ );

    and i got this error

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘my_custom_display_topic_index_query ‘ not found or invalid function name in /home/flexol5/public_html/wp-includes/plugin.php on line 235

    Warning: array_merge(): Argument #2 is not an array in /home/flexol5/public_html/wp-content/plugins/bbpress/includes/common/functions.php on line 1419

    I don’t know what i did wrong or maybe the coding structure of bbpress as changed. I would like someone to help with a way to arrange a specific forum topic in ascending order.

    Thanks

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

  • Robin W
    Moderator

    @robin-w

    if you’ve copied/pasted it from your code, then you have a space after ‘my_custom_display_topic_index_query and before the closing ‘ bracket

    ie

    ‘my_custom_display_topic_index_query '
    

    when it should be

    ‘my_custom_display_topic_index_query' 
    
    

    BekBek20
    Participant

    @bekbek20

    Thank you for your response.

    I have gotten the alphabetical order arrangement.

    Now i want to arrange the a specific forum topics based on ID on the front-end.

    Please help


    Robin W
    Moderator

    @robin-w

    sorry, but I don’t understand exactly what you are trying to do, or whether my previous response helped or not.

    Can you come back please with further detail.


    BekBek20
    Participant

    @bekbek20

    Sorry if my response was not good.

    What i meant was, Your suggestion was together with a few adjustments i made to the code, which i used to get the alphabetically arrangement of a specific forum topic.

    Now i want to arrange another specific forum topic in a specic order using there ID i guess.

    For example, I want to arrange the following topic to another arrangement.

    Topic ID
    I enjoy bbpress 655
    I want bbpress 658
    I love bbpress 660
    bbpress 662

    To be arranged like this

    Topic ID
    I love bbpress 660
    I want bbpress 658
    bbpress 662
    I enjoy bbpress 655

    That’s what i want to do now, I was hoping you could help me.

    Thanks for your time


    Robin W
    Moderator

    @robin-w

    ok, thanks – now I think I understand

    so within a specific forum, you want these topics to appear in that order – can you let me know if there are other topics which also need to appear below – eg these are the first 5 and then all others appear in date order, or are these the only 5 topics?


    BekBek20
    Participant

    @bekbek20

    Thank you very much for your time on this.

    No there are not other items except other forums. The 5 topics above are just demo, The topics in total are about 20 topics.


    Robin W
    Moderator

    @robin-w

    so are these forums within a forum list, or topics within a forum?


    BekBek20
    Participant

    @bekbek20

    I’m not sure i understand your question.

    Here is another explanation of what i meant

    I have 5 forums and each of them as about 20 topics.

    Earlier i asked for help on how to arrange all the topics in one of the forums alphabetically which i got help.

    Now i want to arrange the all the topics in another forum in a specific order which i have highlighted.

    I hope you understand my explanation, How i wish i can get to give you a call or something to pass the message clearly but based on the description above i think that should be clear enough .

    Thanks for your help


    Robin W
    Moderator

    @robin-w

    hmm.. The only way I can immediately think of is to modify loop-topics

    so

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    find
    wp-content/plugins/bbpress/templates/default/bbpress/loop-topics.php
    Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/loop-topics.php
    bbPress will now use this template instead of the original
    and you can amend this

    so in that file you will see

    <?php while ( bbp_topics() ) : bbp_the_topic(); ?>
    
    			<?php bbp_get_template_part( 'loop', 'single-topic' ); ?>
    
    		<?php endwhile; ?>
    

    you would need to check with forum the user is in and then custom display

    so something like – you’d need to write the code – this is just words !

    <?php 
    	if (forum == the one you want to change) {
    		then make an array of the ID, and then cycle through them
    		foreach ($topics as $topic) {
    		bbp_get_template_part( 'loop', 'single-topic' );
    		}
    	}
    	else { ?>
    		<?php while ( bbp_topics() ) : bbp_the_topic(); ?>
    
    			<?php bbp_get_template_part( 'loop', 'single-topic' ); ?>
    
    		<?php endwhile; ?>
    	<?php } ?>
    

    BekBek20
    Participant

    @bekbek20

    Wow…. Thank you, I will try and get back in touch with you.

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