Skip to:
Content
Pages
Categories
Search
Top
Bottom

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


  • vincenzon617
    Participant

    @vincenzon617

    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

    @robin-w

    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

    @vincenzon617

    Works great thank you!


    aygunoz
    Participant

    @aygunoz

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


    Robin W
    Moderator

    @robin-w

    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

    @aygunoz

    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


    aygunoz
    Participant

    @aygunoz

    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

    @robin-w

    amended in the original code to add the missing ;


    aygunoz
    Participant

    @aygunoz

    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

    @robin-w

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


    aygunoz
    Participant

    @aygunoz

    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

    @robin-w

    you would do better to use the bbpress widget

    (bbPress) Recent Topics

    which lets you set a number


    aygunoz
    Participant

    @aygunoz

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


    Robin W
    Moderator

    @robin-w

    πŸ™‚


    jollykhatun
    Participant

    @jollykhatun

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


    MrsJessicaSimpson
    Participant

    @mrsjessicasimpson

    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

    @robin-w

    πŸ™‚

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