Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1017365

    I create some parent portfolios and child portfolio into these, and in the child portfolios I create many child-child-portfolio. When I show the portfolio parent, all the child-child-portfolio are showed.
    I want to show only the child-portfolio, 1st heritage of parent portfolio. Can I do that?
    Please help me

    #1017941

    Hey ezvisa,

    Thank you for using Enfold.

    Can we take a peek at the site? We need to see the actual setup of your portfolio items and categories.

    Best regards,
    Ismael

    #1017956

    I can’t show you. But I can explain more clearly then:
    – My first Portfolio belong to Portfolio Category 1
    – My second belong to Category 2 – Child of Portfolio Category 1.
    When I show all the Portfolio Grid from Portfolio Category 1, all the portfolio are showed, include the second. I Dont want that, I want only the portfolio directly belong to Portfolio Category 1 are showed.
    That my problem. Please help me

    #1018732

    Hi,

    Thanks for the update.

    You can use this filter in the functions.php file to exclude the sub categories.

    function array_unshift_assoc(&$arr, $key, $val) 
    { 
        $arr = array_reverse($arr, true); 
        $arr[$key] = $val; 
        $arr = array_reverse($arr, true); 
        return $arr;
    }
    
    // portfolio query
    add_filter( 'avia_post_grid_query', 'avia_post_grid_query_mod', 1000, 2);
    function avia_post_grid_query_mod( $query, $params ) {
        $child_cats = (array) get_term_children( $params['categories'], 'portfolio_entries' );
        if ( ! is_admin() ) {
            // exclude the posts in child categories
            array_unshift_assoc($query['tax_query'], 'relation', 'AND');
            $query['tax_query'][] =  array(
    			'taxonomy' => 'portfolio_entries',
    			'field'    => 'term_id',
    			'terms'    => array(implode(',', $child_cats)),
    			'operator' => 'NOT IN',
    		);
        }
    
    	return $query;
    }

    Best regards,
    Ismael

    #1019300

    That’t not work. It still show all of the category 2 portfolio item.
    In homepage -> Visa đầu tiên –> “Visa Mỹ: belong to Category 1
    Visa du lich My va Visa Cong tac My belong to Category 2 and they are showed when I choose Category 1

    #1019305

    Hi,

    Can I have access to the dashboard? The filter excludes items from the child categories when I test it on my installation.

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.