Skip to:
Content
Pages
Categories
Search
Top
Bottom

filter topics by post_meta value


  • shanebp
    Participant

    @shanebp

    I need to filter the topics in a single forum based on a post_meta value.

    Currently, I’m over-riding the loop-topics.php template.

    So which hook or filter should be used to pass in query args?
    Or even better a csv string of topic ids?

    It seems the topics are gathered in a template other than loop-topics.php ?
    Perhaps I should be over-riding a different template?

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

  • shanebp
    Participant

    @shanebp

    It seems that content-single-forum.php is the template to over-ride.

    So do I have to pass in WP_Query meta_query args to bbp_has_topics() ?

    I’d like to only gather the appropriate topics, so using the supplied apply_filters
    apply_filters( 'bbp_has_topics', $bbp->topic_query->have_posts(), $bbp->topic_query );
    seems inefficient.

    Or is there an easier way?


    shanebp
    Participant

    @shanebp

    This seems to work – there may be a better way…

    In an over-ride of content-single-forum.php, do something like this:

    if ( // some condition ) {
     
    	$my_r['meta_query'] = array(
    		array(
    		'key' => 'my_key',
    		'value' => 'my_value',
    		'compare' => '=',
    		)
    	);
    }
    else
    	$my_r = ''; 

    Then change bbp_has_topics() to bbp_has_topics( $my_r )

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

You must be logged in to reply to this topic.