This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Posts Showcase – filter by custom taxonomy

  • Creator
    Topic
  • #23742
    ajvanliere
    Member

    Hi, I am using a custom post type on the showcase with filtered masonary but there is no where to enter in a custom taxonomy name. So I was getting no filter showing.

    I have have made a couple of changes to the framework in order to get my taxonomy filter to work but this is not really how I would like to do it.

    How can I correctly pass my custom taxonomy name through to the filter nav.

    Thanks
    loop.php – added in my $tax parameter “topic”

    if ( $args['display'] == 'filter' || $args['display'] == 'masonry_filter' ) {
    		themeblvd_filter_nav($posts, 'topic',$args['filter']);
    	}

    parts.php – changed the start of data-filter from data-filter=”.filter- to data-filter=”.’.$tax.’-

    foreach ( $terms as $key => $value ) {
    			$output .= sprintf('
  • %2$s
  • ', esc_attr($key), esc_html($value)); }
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #23748
    Jason Bobich
    Keymaster

    Hi,

    I don’t believe anything needs to be changed within the theme. If you pass through your taxonomy slug, it should work. Passing in your taxonomy slug should just mean making it a selection from the Post Showcase layout builder element, so the correct value can get saved to the element’s options. The Portfolios plugin does this, if you want to use it as an example.

    From your child theme’s functions.php, you’d basically just be doing what the portfolios plugin does here, in order to add your value to the layout builder’s options.

    https://github.com/themeblvd/portfolios/blob/master/tb-portfolios.php#L205

    But knowing that you only want to modify the post_showcase element, you could simplify this to be something more like this:

    function my_elements( $elements ) {
    	$elements['post_showcase']['options']['filter']['options']['topic'] = 'Filtered by topic';
    	return $elements;
    }
    add_filter('themeblvd_elements', 'my_elements');

    Note that the above code is modifying specifically this in the layout builder plugin. Knowing what you’re editing can help you to understand the complex traverse of array within array you see in the code snippet I just wrote.

    This is sort of off the top of my head. Let me know if this doesn’t work.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.