Filter Sub category in Portfolio in finch theme
-
Hi I want to display only parent category but this code shows subcategory too. am not able to remove subcategory from this .
and one more thing how I can show only one parent category with subcategory..
<?php class AQ_Portfolio_Block extends AQ_Block { //set and create block function __construct() { $block_options = array( 'name' => 'Portfolio', 'size' => 'span12', 'resizable' => 0, 'block_description' => 'Add a feed of Portfolio posts to the page.', 'block_category' => 'feeds', 'block_icon' => '<i class="fa fa-fw fa-paint-brush"></i>' ); parent::__construct('aq_portfolio_block', $block_options); }//end construct function form($instance) { $defaults = array( 'type' => 'classic', 'pppage' => '999', 'filter' => 'all', 'show_filter' => 1 ); $instance = wp_parse_args($instance, $defaults); extract($instance); $args = array( 'orderby' => 'name', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => 'portfolio_category' ); $filter_options = get_categories( $args ); $portfolio_types = array( 'classic' => 'Classic Masonry', 'masonry' => 'Fixed Masonry', 'full' => 'Full Width', 'classic-lightbox' => 'Classic Masonry Lightbox', 'masonry-lightbox' => 'Fixed Masonry Lightbox', 'full-lightbox' => 'Full Width Lightbox' ); ?>
and this
<?php }//end form function block($instance) { extract($instance); /** * Initial query args */ $query_args = array( 'post_type' => 'portfolio', 'posts_per_page' => $pppage ); /** * If we're choosing just 1 category, add more args. * GRAB ALL THE ARGS! */ if (!( $filter == 'all' )) { if( function_exists( 'icl_object_id' ) ){ $filter = (int)icl_object_id( $filter, 'portfolio_category', true); } $query_args['tax_query'] = array( array( 'taxonomy' => 'portfolio_category', 'field' => 'id', 'terms' => $filter ) ); } /** * Finally, here's the query. */ $block_query = new WP_Query( $query_args ); /** * Now let's grab categories for the animated portfolio filter buttons */ $cats = ( $filter == 'all' ) ? get_categories('taxonomy=portfolio_category') : get_categories('taxonomy=portfolio_category&exclude='. $filter .'&child_of='. $filter); if( 'classic' == $type ) : ?>
and output via this
if( 1 == $show_filter ) echo ebor_portfolio_filters($cats);
help me out to show only main category !
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Filter Sub category in Portfolio in finch theme’ is closed to new replies.