Okay
  Public Ticket #2125495
Can I hide specific portfolio categories
Closed

Comments

  •  2
    imthazahamed started the conversation

    Hello there, 

    Is there a way of hiding only specific portfolio categories ? 

    Right now if i add in a category it comes up on the portfolio page, I'd like to hide certain categories on the front end of the website but have them for my use on the admin side of things.

    I'd also be happy if i can hide them from the portfolio categories bar at the top and for them to appear only when hovered over the photos.


    Thanks


  • [deleted] replied

    Hi imthazahamed,

    I have created a code snippet for you to exclude portfolio categories from query:

    add_filter( 'kalium_portfolio_pre_query', function ( $query ) {
        if ( empty( $query['tax_query'] ) ) {
            $query['tax_query'] = [];
        }
        $query['tax_query'][] = [
            'taxonomy'         => 'portfolio_category',
            'field'            => 'slug',
            'operator'         => 'NOT IN',
            'include_children' => true,
            'terms'            => [
                // Term slugs to exclude
                'term-1-slug',
                'term-2-slug',
            ],
        ];
        return $query;
    } );

    So add the code in functions.php and modify the list of terms to exclude (term-1-slug, term-2-slug) you can add a single or more categories.

    Here is a video that shows how you can use the code and retrieve portfolio category slugs you want to exclude:

    https://d.pr/v/4QprNY

  •  2
    imthazahamed replied

    Hi Arlind,

    Thanks a lot for your reply, but that is not exactly what i want. Right now if I use your code, the categories go missing and so do the pictures that belong to that category.

    All i want is for those pictures to remain in my portfolio but certain tags to be hidden in the top line of tags ( see attachement) for eg. I'd want the pictures with the tag 'iPhone' to be visible on the main page but not the name 'iPhone' on the row of tags.

    Please let me know if that is possible.

    And again, thanks a lot for your help :) 

  • [deleted] replied

    Hi,

    Aha, I understand what are you looking to achieve so this is simpler than the previous code I sent you. So you can only use CSS to hide the filter item with CSS by inspecting the element with DevTools to get CSS selector:

    https://d.pr/v/zlfNGY

    I hope this will help you.

  •  2
    imthazahamed replied

    Thanks a lot Arlind, that worked :)

  • [deleted] replied

    I'm happy to hear thatsmile.png

    I wish you have a nice day!

    P.S: If you like the theme, it would help us a lot if you could give us a five-star rating on Themeforest from your Downloads tab.

    A huge thank you from me and Laborator in advance.