Skip to:
Content
Pages
Categories
Search
Top
Bottom

Customize Shortcodes


  • shake1
    Participant

    @shake1

    Excuse me for asking a question about customization.
    I am using a translation tool, so my English may be unnatural.

    I would like to limit the posts displayed in [bbp-single-view id='popular'] to 7 days.

    
    function filter_bbp_get_view_query_args( $args, $view ) {
        // Check if the view exists
        if ( ! bbp_get_view( $view ) ) {
            return new WP_Error( 'invalid_view', __( 'Invalid view specified.', 'bbpress' ), $view );
        }
    
        if ( 'popular' === $view ) {
            $args['date_query'] = array(
                array(
                    'after' => '1 week ago',
                ),
            );
        }
        return $args;
    }
    add_filter( 'bbp_get_view_query_args', 'filter_bbp_get_view_query_args', 10, 2 );
    
    
Viewing 1 replies (of 1 total)

  • shake1
    Participant

    @shake1

    I made the following because of an error, does it look ok?

    
    function filter_bbp_get_view_query_args( $args, $view ) {
        // Check if the view exists
        if ( function_exists( 'bbp_get_view' ) ) {
            if ( ! bbp_get_view( $view ) ) {
                return new WP_Error( 'invalid_view', __( 'Invalid view specified.', 'bbpress' ), $view );
            }
        }
    
        if ( 'popular' === $view ) {
            $args['date_query'] = array(
                array(
                    'after' => '1 week ago',
                ),
            );
        }
        return $args;
    }
    add_filter( 'bbp_get_view_query_args', 'filter_bbp_get_view_query_args', 10, 2 );
    
    
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar