Skip to:
Content
Pages
Categories
Search
Top
Bottom

[bbpress 2 plugin] – Forum order doesn't work? – not appearing in correct order


  • Laughing Cat
    Participant

    @laughing-cat

    Hi

    I’m running WP3.3.1 and bbP 2.1

    my forums are are not being listed in the front page archive or forum summary pages in the correct order; I double checked many times the ordering number, but no matter what, the forums will display in their own order which is neither alphabetical, cronological (date created/updated) or other. I can’t just figure it out. I’ve tried also re-arranging forums with simple page ordering plugin, no success.

    How can I list forums correctly?

    thank you

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

  • Laughing Cat
    Participant

    @laughing-cat

    mmm it looks like forums are being ordered in the list by their ID and not page/number order

    how to enforce set page/number order to list them appropriately in the forum front page?

    thank you

    Temporarily switch you theme to TwentyEleven and see if that fixes the problem. That will rule out your theme being the cause.


    Laughing Cat
    Participant

    @laughing-cat

    exactly the same, I don’ think it’s a theme issue, because I haven’t touched the bbPress template files yet, as it is now it’s stock bbPress loading inside my theme – the same happens if I load another theme such as TwentyEleven

    Hmm weird. Next I would deactivate all plugins except bbPress to make sure one isnt screwing with the loop or query vars.


    Laughing Cat
    Participant

    @laughing-cat

    Done that too, anyway there’s nothing else being loaded on forums besides forums, as I said I haven’t touched yet the template files, just copypasted into my theme. Other than the forums themselves, in the forum pages, there are being loaded just wordpress menus. As I said it looks like they are ordered in the frontend based on their ID not on the page order. Which is the function listing all the forums in the template files? Can I try perhaps forcing the order or if I know which is the function responsible for that perhaps I can throw some PHP to reorder them manually – in this case may I know how it is stored the ordering variable?

    thanks


    Laughing Cat
    Participant

    @laughing-cat

    I’m thinking… could this be due to the fact I did import all my forums from a previous 1.x standalone installation to a 2.x installation?

    The import was fine, I got all my users, topics and replies back. As well as forums. However, there might have been something there, that doesn’t allow me now to set the forum order? Eventually could I force it by looking into the database?

    any hint?

    thanks


    Laughing Cat
    Participant

    @laughing-cat

    Any updates on this?

    Hello,

    I’m using the bbPress Forum list widget and [bbp-forum-index] Shortcode.

    I’ve changed these lines to list by title:

    wp-content/plugins/bbpress/bbp-includes/bbp-forum-template.php

    Line #88

    ‘orderby’ => ‘menu_order’,

    changed for:

    ‘orderby’ => ‘title’,

    wp-content/plugins/bbpress/bbp-includes/bbp-core-widgets.php

    Line #387

    ‘orderby’ => ‘menu_order’,

    changed for:

    ‘orderby’ => ‘title’,

    https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters


    knaveenchand
    Participant

    @knaveenchand

    Thanks for the hint provided by @Rafael. I would like to add here that in order to keep the change in tact, it is better to edit it through our functions.php file in our theme directory so that even if bbpress gets updated, our changes remain intact. So I created these two functions along add_filter functions:

    /**
     * The main forum loop. THIS IS CUSTOMISED TO ORDERBY TITLE INSTEAD OF MENU_ID
     *
     * WordPress makes this easy for us.
     *
     * @since bbPress (r2464)
     *
     * @param mixed $args All the arguments supported by {@link WP_Query}
     * @uses WP_Query To make query and get the forums
     * @uses bbp_get_forum_post_type() To get the forum post type id
     * @uses bbp_get_forum_id() To get the forum id
     * @uses get_option() To get the forums per page option
     * @uses current_user_can() To check if the current user is capable of editing
     *                           others' forums
     * @uses apply_filters() Calls 'bbp_has_forums' with
     *                        bbPres::forum_query::have_posts()
     *                        and bbPres::forum_query
     * @return object Multidimensional array of forum information
     */
    function mybbp_has_forums( $args = '' ) {
    	$bbp = bbpress();
    
    	// Setup possible post__not_in array
    	$post_stati[] = bbp_get_public_status_id();
    
    	// Check if user can read private forums
    	if ( current_user_can( 'read_private_forums' ) )
    		$post_stati[] = bbp_get_private_status_id();
    
    	// Check if user can read hidden forums
    	if ( current_user_can( 'read_hidden_forums' ) )
    		$post_stati[] = bbp_get_hidden_status_id();
    
    	// The default forum query for most circumstances
    	$defaults = array (
    		'post_type'      => bbp_get_forum_post_type(),
    		'post_parent'    => bbp_is_forum_archive() ? 0 : bbp_get_forum_id() ,
    		'post_status'    => implode( ',', $post_stati ),
    		'posts_per_page' => get_option( '_bbp_forums_per_page', 50 ),
    		'orderby'        => 'title',
    		'order'          => 'ASC'
    	);
    	$bbp_f = bbp_parse_args( $args, $defaults, 'has_forums' );
    
    	// Run the query
    	$bbp->forum_query = new WP_Query( $bbp_f );
    
    	return apply_filters( 'mybbp_has_forums', $bbp->forum_query->have_posts(), $bbp->forum_query );
    }
    add_filter('bbp_has_forums','mybbp_has_forums');
    
    //this is CUSTOMIZED to just get the subforums ordered by title instead of menu_id
    
    function myybbp_forum_get_subforums( $args = '' ) {
    
    	// Use passed integer as post_parent
    	if ( is_numeric( $args ) )
    		$args = array( 'post_parent' => $args );
    
    	// Setup possible post__not_in array
    	$post_stati[] = bbp_get_public_status_id();
    
    	// Super admin get whitelisted post statuses
    	if ( is_super_admin() ) {
    		$post_stati = array( bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id() );
    
    	// Not a super admin, so check caps
    	} else {
    
    		// Check if user can read private forums
    		if ( current_user_can( 'read_private_forums' ) ) {
    			$post_stati[] = bbp_get_private_status_id();
    		}
    
    		// Check if user can read hidden forums
    		if ( current_user_can( 'read_hidden_forums' ) ) {
    			$post_stati[] = bbp_get_hidden_status_id();
    		}
    	}
    
    	$defaults = array(
    		'post_parent'    => 0,
    		'post_type'      => bbp_get_forum_post_type(),
    		'post_status'    => implode( ',', $post_stati ),
    		'posts_per_page' => get_option( '_bbp_forums_per_page', 50 ),
    		'orderby'        => 'title',
    		'order'          => 'ASC'
    	);
    	$r = bbp_parse_args( $args, $defaults, 'forum_get_subforums' );
    	$r['post_parent'] = bbp_get_forum_id( $r['post_parent'] );
    
    	// No forum passed
    	$sub_forums = !empty( $r['post_parent'] ) ? get_posts( $r ) : '';
    
    	return apply_filters( 'mybbp_forum_get_sub_forums', (array) $sub_forums, $args );
    }
    add_filter('bbp_forum_get_sub_forums','mybbp_forum_get_sub_forums');
    

    This may not be elegant solution but it saves us from the annoying impacts on bbpress updates.

    I would love to hear from developers on this forum on how best this can be implemented without copy-pasting the entire function just to change one small variable and then giving it a new function name and then adding filters. Is there a better way, friends?


    screenprotector
    Participant

    @screenprotector

    hi, i am having this problem of the numbering i have entered not being reflected in the forum. Are there any solutions that dont involve changing the php?
    thanks

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