• Hi,

    Been trying to hide the Uncategorized category from view.

    Tried the following code in Funtion.php but it doesn’t work as i think it addresses woocommerce but not WP Crowdfunding

    code used from here

    add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
    function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
    $new_terms = array();
    // if it is a product category and on the shop page
    if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() ) {
    foreach( $terms as $key => $term ) {
    if ( !in_array( $term->slug, array( 'uncategorised' ) ) ) { //pass the slug name here
    $new_terms[] = $term;
    }}
    $terms = $new_terms;
    }
    return $terms;
    }

    Can you send me the code to do it?

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter jpsarmento

    (@jpsarmento)

    it would be great to get a reply here…

    i’ve tried to hide by tags such as:

      function exclude_specific_tag( $q ) {
        if (is_shop()){
            $tax_query = (array) $q->get( 'tax_query' );
            $tax_query[] = array(
                'taxonomy' => 'product_tag',
                'field' => 'slug',
                'terms' => array( 'uncategorized' ), // tag name to hide ''
                'operator' => 'NOT IN'
            );
            $q->set( 'tax_query', $tax_query );
        }
    }
    add_action( 'woocommerce_product_query', 'exclude_specific_tag' );

    I guess this all applies to woocommerce and not to Campaigns from WP Crowdfunding.

    Can anyone come back to this?
    txs
    j

    • This reply was modified 2 years, 10 months ago by jpsarmento.
    Plugin Support Md. Jobayer Al Mahmud

    (@jobayertuser)

    Hello @jpsarmento,

    Do you want to hide the Campaign category wise?

    Thread Starter jpsarmento

    (@jpsarmento)

    yes, as mentioned above ‘hide the Uncategorized category from view.’ in the campaign

    txs

    • This reply was modified 2 years, 10 months ago by jpsarmento.
    Thread Starter jpsarmento

    (@jpsarmento)

    6 days since i posted this issue… nothing happening….

    Thread Starter jpsarmento

    (@jpsarmento)

    Hi @jobayertuser ,

    It turns out i still need this.

    Can you let me know the code to hide a category from being displayed on the ‘latest’ and ‘all campaigns’ please?
    please let me know.

    thank you, J

    Plugin Support Md. Jobayer Al Mahmud

    (@jobayertuser)

    Hello @jpsarmento,

    I am sorry but we don’t have any snippets or code for this and as all crowdfunding list as a product so this is part of woocommerce you can try to contact their support I hope they can help you better in this use case.

    Hello @jpsarmento!

    Do you want to remove this from the shop page or from where? can you explain, please

    You can try this code

    add_filter( 'woocommerce_product_categories_widget_args', 'remove_uncategorized_category' );
    add_filter( 'woocommerce_product_subcategories_args', 'remove_uncategorized_category' );
    
    function remove_uncategorized_category( $args ) {
      $uncategorized = get_option( 'default_product_cat' );
      $args['exclude'] = $uncategorized;
      return $args;
    }

    Thank you!

    Thread Starter jpsarmento

    (@jpsarmento)

    Hi,

    Thank you both your replies.

    Hi @jobayertuser

    Thank you for your reply.

    I’ve tested the feature with common Woocommerce products and it worked perfectly. However, it never worked with products/campaigns from WP Crowdfunding. That suggests that the issue is with WP Crowdfunding, and not with Woocommerce. Given that you are the authors of the plugin, maybe you should liase with woocommerce to fix the issue, or TheMeum could address the code, so that the ‘Hidden’ feature works.

    Thread Starter jpsarmento

    (@jpsarmento)

    hi @kardi420

    thanks for your reply.

    The Code you kindly supplied did not work, and created an error, even when pasting it in the Functions.php doc.

    To your question “Do you want to remove this from the shop page or from where? can you explain, please” :

    – I want to keep some campaigns hidden from the general public, so that only people with a link can find them. So, they shouldn’t show up on the public category results, or the front page, or in search results. In essence, what can be done with Woocommerce products. Hope that answers your question.

    Thank you,
    J

    Hello @jpsarmento!

    You can show a specific list by shortcode
    https://docs.themeum.com/wp-crowdfunding/shortcodes/#crowdfunding-project-listing-shortcode

    Then, your private category crowdfunding list will not show on that page, you can share that privately.

    Thank you!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Hide category’ is closed to new replies.