• I’m using ID’s right now to display child portfolio types within two parent portfolio types “portfolios” and “topics.”

    The parent portfolio types will remain this way, but the child portfolio types will change over time. I would like a more dynamic way of doing this, so that when we add a new child category, we don’t have to add the ID in the array each time.

    <div class="portfolio-filter block clearfix">
    			<?php
    				$portfolio = zilla_get_option('general_portfolio_page');
    				$pub_terms_args = array(
    					'include' => array(14,15,16,17,18,19,21)
    					);
    				$pub_terms = get_terms( 'portfolio-type', $pub_terms_args);
    
    				if( !empty($pub_terms) ) {
    					echo '<h5>' . __( 'Filter By Publication:', 'zilla' ) . '</h5>';
    					echo '<ul>';
    					echo '<li><a href="' . get_permalink($portfolio) . '" class="active" data-filter="*">' . __('All', 'zilla') . '</a></li>';
    					foreach( $pub_terms as $pub_term ) {
    						echo '<li><a href="' . get_term_link($pub_term) .'" data-filter=".' . $pub_term->slug .'">' . $pub_term->name . '</a></li>';
    					}
    
    					echo '</ul>';
    				}
    
    				$top_terms_args = array(
    					'include' => array(2,3,4,5,6,7,8,9,10,11,20,23)
    					);
    				$top_terms = get_terms( 'portfolio-type', $top_terms_args);
    
    				if( !empty($top_terms) ) {
    					echo '<br/>';
    					echo '<h5>' . __( 'Filter By Topic:', 'zilla' ) . '</h5>';
    					echo '<ul>';
    					foreach( $top_terms as $top_term ) {
    						echo '<li><a href="' . get_term_link($top_term) .'" data-filter=".' . $top_term->slug .'">' . $top_term->name . '</a></li>';
    					}
    
    					echo '</ul>';
    				}
    			?>
    		</div>
  • The topic ‘[Theme: Sparks] Portfolio Filter sort by parent category’ is closed to new replies.