Skip to:
Content
Pages
Categories
Search
Top
Bottom

Number of topics per page post_type


  • galiulinr
    Participant

    @galiulinr

    https://bbpress.org/forums/topic/shortcode-on-the-page-php
    I added [bbp-single-forum id=$forum_id] page post_type, how to make that outputs only 5 replies.
    I added this code here:

    
    function bbp_single_topic_query() {
    		if(is_singular( 'download' )) {
    		if ( bbp_has_topics( array( 'author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 5 ) ) )
                    bbp_get_template_part( 'loop', 'latest-topics' );   
          }
    return;
    	  }
    add_action('bbp_template_before_topics_loop','bbp_single_topic_query');

    it does not work for me. I maybe doing wrong?

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

  • Robin W
    Moderator

    @robin-w

    my plugin

    bbp additional shortcodes

    creates that list

    either use the plugin, or crack the code open to see what parameters I set


    galiulinr
    Participant

    @galiulinr

    Unfortunately I learn php 10 months, and did not know too much. I add this code:

    function bbp_single_replies_show($args) {
    $args['posts_per_page'] = 3 ;
    return $args;
    }
    add_filter('bbp_before_has_replies_parse_args','bbp_single_replies_show');

    it does not work for me. I looked at your plugin, but highlight the desired fragment, I could not. I thought it would be easy, you can help me?


    Robin W
    Moderator

    @robin-w

    try

    function bbp_single_replies_show($args) {
    $args['posts_per_page'] = 3 ;
    $args['max_num_pages'] = 1;
     return $args;
     }
     add_filter('bbp_before_has_replies_parse_args','bbp_single_replies_show');
    

    I have not tested – I am quite busy at the moment – but keep trying !


    galiulinr
    Participant

    @galiulinr

    Thank you Robin!
    This code works for me.

    function bbp_single_replies_show($args) {
    if(is_singular( 'download' )) {
    $args['posts_per_page'] = 3 ;
    $args['max_num_pages'] = 1;
    }
    return $args;
    }
    add_filter('bbp_before_has_replies_parse_args','bbp_single_replies_show');

    Now I have a custom page type post comments remove, and set the theme forum with the number of responses 3. Thank you very much.


    Robin W
    Moderator

    @robin-w

    no problem, glad you’re fixed

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