Skip to:
Content
Pages
Categories
Search
Top
Bottom

Is it possible to loop bbp_register_view ?


  • wpman
    Participant

    @iwpman

    I have a taxonomy:location
    I try to register views for all terms.but it doesn’t work.


    function taxonomy_custom_views() {
    $args = array('orderby'=>'asc','hide_empty'=>true);
    $terms = get_terms(array('location'), $args);
    foreach($terms as $term){
    $location_term=$term->slug ;
    $location_name=$term->name ;
    bbp_register_view( $location_term , __( $location_name ),array('tax_query' => array(array('taxonomy' => 'location','field' => 'slug','terms' => $location_term,),),), false );
    }
    }
    add_action( 'bbp_register_views', 'taxonomy_custom_views' );

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

  • wpman
    Participant

    @iwpman

    @robkk
    Is it possible ?


    Robkk
    Moderator

    @robkk

    I have never tried anything like this yet so can’t say, sorry.


    mrentropy
    Participant

    @mrentropy

    I realize this topic is more than six years old, but I’ve been attempting to achieve similar behavior, and adding the following code in a custom plug-in seems to work. I have a taxonomy of “ideacategory” and I’m able to create a bbPress view called “ideacat” that filters all of the topics where the category term is equal to “24-hour-market-watch.”

    function idea_register_custom_views() {
    		
    	bbp_register_view(
    		'ideacat',
    			esc_html__( 'Idea Category', 'bbpress' ),
    			apply_filters( 'bbp_register_view_ideacat', array(
    			'tax_query' => array(
    				array(
    					'taxonomy' => 'ideacategory',
    					'field' => 'slug',
    					'terms' => array( '24-hour-market-watch' )
    				)
    			),
    			'show_stickies' => false
    			)
    		) );
    
    }
    
    add_action( 'bbp_register_views', 'idea_register_custom_views' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar