Skip to:
Content
Pages
Categories
Search
Top
Bottom

Limit the amount of topics shown from content-single-view

  • @vincenzon617

    Participant

    Is there a way to limit the number of topics shown when using the shortcode [bbp-single-view id=’popular’]?

    I would only like to show the top 10 most popular topics.

    Thanks

Viewing 17 replies - 1 through 17 (of 17 total)
  • @robin-w

    Moderator

    untested, but try

    add_filter( 'bbp_get_view_query_args', 'rew_limit') ;
    
    function rew_limit ($args) {
    $args['posts_per_page'] = -1 ;
    $args['posts_per_page'= 10 ;
    return $args ;
    }

    not sure which 10 it will show!!

    @vincenzon617

    Participant

    Works great thank you!

    @aygunoz

    Participant

    Where shall I put this code? This is what exactly I was looking for :)?

    @robin-w

    Moderator

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

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

    or use

    Code Snippets

    @aygunoz

    Participant

    Okay, I found the functions.php but I confuse about this code add_filter( 'bbp_get_view_query_args', 'rew_limit') Bc there are functions but there are not any code like this. So Shall I paste this there too? And after paste what’s gonna be shortcut ?
    Thank You!

    @aygunoz

    Participant

    @aygunoz

    Participant

    There is one think will be different then this solution. I want to limit topic for [bbp-topic-index] shortcut. You can see the picture.Click for view

    @robin-w

    Moderator

    amended in the original code to add the missing ;

    @aygunoz

    Participant

    So how can I edit this code for [bbp-topic-index] shortcut and Implementation to my WordPress plugin? If you please, Can you explain more bc I didn’t understand exactly what to do :/ Sorry.
    Thank you for helping

    @robin-w

    Moderator

    sorry, cab you explain what you want to show in [bbp-topic-index] ? just the first 10 topics ????

    @aygunoz

    Participant

    Okay, sorry, maybe I didn’t explain well. I have forum for University. Forum is so simple design. We will not have much topics. So I want to limit [bbp-topic-index] shortcut in sidebar with max 3 topics limit. I will share the screen shoot, If you want to see. It can explain better maybe.
    Thank you
    ScreenShootFromWebsite

    @robin-w

    Moderator

    you would do better to use the bbpress widget

    (bbPress) Recent Topics

    which lets you set a number

    @aygunoz

    Participant

    Yeah, I realize all I need. Thank you a lot. It was so easy πŸ™‚

    @robin-w

    Moderator

    πŸ™‚

    @jollykhatun

    Participant

    I would like to show the top 8 most popular topics.

    @mrsjessicasimpson

    Participant
    add_filter( 'bbp_get_view_query_args', 'rew_limit') ;
    
    function rew_limit ($args) {
    $args['posts_per_page'] = -1 ;
    $args['posts_per_page'] = 10 ;
    return $args ;
    }

    Following this, and looking at it: then a bracket ‘]’ might be missing where the (= 10) line is.
    Which could explain the unexpected T_FUNCTION error.

    Got this code running on my site, (in the functions.php file), and it seems to work.

    Happy-hacking.

    @robin-w

    Moderator

    πŸ™‚

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