Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to start a new loop?

Viewing 7 replies - 1 through 7 (of 7 total)
  • @lynq

    Participant

    You can copy and paste a current loop file and rename to something like loop-custom-forums.php then when you want to call that loop you can use:

    <?php bbp_get_template_part( 'bbpress/loop', 'custom-forums' ); ?>

    Good luck!

    @kennymcnett

    Member

    Thanks, Lynq. I’ve seen your posts around these support forums and I appreciate your help and time.

    What I’m really trying to do is apply a filter to the query that creates the loop (so I can filter the list of forums that gets displayed). Any ideas on how to create a new filtered query and/or filter the existing one?

    Perhaps via bbp_has_forums() ?

    @lynq

    Participant

    Yes you can use bbp_has_forums() and pass it some arguments to filter the query. for example something like:

    if ( bbp_has_forums( array( 'posts_per_page' => 1, 'max_num_pages' => 1 ) ) )
    bbp_get_template_part( 'bbpress/loop', 'forums' );

    This will filter the loop depending on what arguments you pass bbp_has_forums. I am not too sure on what filter or action you could use that to get that working on all queries.

    Default arguments for bbp_has_forums.

    // The default forum query for most circumstances
    $default = 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' => 'menu_order',
    'order' => 'ASC'
    );

    No problem for helping btw, I try to help as much as I can, I may just get in the way sometimes :p

    @installuninstallcom

    Member

    loop.php page will work for genesis framework?

    @bookespana

    Member

    //Map bbPress topics to WordPress posts structure.

    foreach($bb_topics as $bb_topic){

    $bb_first_post = $wpdb->get_results(“SELECT post_text FROM bb_posts WHERE post_position = ‘1’ AND topic_id = $bb_topic->topic_id”, ARRAY_A);

    $bb_post->post_author = $bb_topic->topic_poster;

    $bb_post->post_date = $bb_topic->topic_start_time;

    $bb_post->post_content = $bb_first_post[0][post_text];

    $bb_post->post_title = $bb_topic->topic_title;

    $bb_post->post_status = “publish”;

    $bb_post->comment_status = “open”;

    $bb_post->ping_status = $bb_topic->post_id;

    $bb_post->post_name = “forums/topic/”.$bb_topic->topic_slug;

    $bb_post->post_type = “forum_topic”;

    $bb_post->comment_count = $bb_topic->topic_posts-1;

    //add bbPress topic to WordPress posts array.

    $wp_posts[] = $bb_post;

    };

    ?>

    Flamenco Shows In Madrid

    Ballet Flamenco Madrid

    @mcla345pau

    Member

    Thanks to the all adviser for their advise because i can start my bbPress loop which i could not before.

    @fuzzybee

    Participant

    Hi Lynq, thanks for pointing that out.

    Do you know anywhere this is documented in great details?

    I’m trying to loop through the forums and sort them by the forums’ names.
    It mentions here that bbp_has_forums() takes the same argument as wp_query.

    However, the following do not work for me at all, no errors thrown either, nothing compared to having no arguments passed to bbp_has_forums()

    $args = array(
    ‘post_type’ => ‘forum’,
    ‘post_status’ => ‘publish’,
    //’meta_key’ => ‘age’,
    ‘orderby’ => ‘title’,
    ‘order’ => ‘ASC’,
    );

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