Hide product categories in the page
*@Link https:\/\/gist.github.com\/stuartduff\/bd149e81d80291a16d4d3968e68eb9f8#file -WC exclude product category from shop page PHP
*The
*\/The
Function prefix\u custom\u pre\u get\u posts\u query ($q){
If (is|shop() |is|u page (\
$tax\u query= (array) $q->get (\
$tax_query[]= array(
\
\
Operator = > none
);
$q->set (‘tax\u query’, $tax\u query);
}The
}The
This code is for pages that do not want to display product categories$ The value of the tax_query array must be set to the value of the category to be removed. The
What to do? Use the \
This script helps to delete categories from artifacts without displaying the woocommerce category. Filter the woocommerce_product\categories\widget\args hook. The codes are as follows: Add\u filter (‘woocommerce\u product\categories\widget\args’,’organcweb\exclude\widget\category’);
Features organicweb_exclude\widget\category ($args){
\/\/Enter the ID of the category to be excluded from the \
$args[‘exclude’] = array (’30’);
Returns $args.
}How to hide categories from users can control more people who can and cannot view categories. This is especially useful if you want to hide categories from users. On the store page of woocommerce users, the hidden category functions are as follows: The
Male add\u filter (‘woocommerce\u product\query\tax\u query’,’hwn\u hide\shop\categories\u by\u role’);
Function hwn\u hide\shop\categories\u by\u role ($tquery){
$user = wp\u get\u current\u user();
$blockd_user_roles=array (\
$hidden_categories=array (\
If (is_shop() & & (! Is_user_logged_in() | is_user_logged_in() & & count (array_intersect ($blocked_user_roles, $user->roles)) > 0)){
$tquery[]=
Sort(
\
\
\
Operator = > none
);
}The
Return $tquery;
}The
This code works as follows: The
In essence, this code is similar to the code above. However, the code uses the wp\u get\u current\u user function to get the details of the current user. You can then define roles to hide categories. Use this code to send tshirt and Hoodie to selected users
Display only categories are defined. The category will be hidden with this code. If (is_shop() & & (! Is_user_logged_in() | is_user_logged_in()&&
Count (array_interact ($blockd_user_roles, $user->roles) >0) the code works as follows: The first part of the if statement checks that it is on the same page as the previous part and determines whether the user is still logged in. If you are a blocked user, you cannot view blocked users. Category. The function of the topic. Don’t forget to use the code in your PHP file. The
In this tutorial, let’s first look at how to remove a product from a category instead of deleting a product from a category. You may not want to display products in a specific category that were previously deleted. Now, what if the unclassified and furniture categories are not displayed, but the products of these categories are not displayed? The screenshot shows two products in the furniture category. Function. You must add it to your PHP file. Add\u action (‘woocommerce\u product\u query’,’ts\custom\u pre\get\u posts\u query’);
Functions ts\u custom\u pre\get\u posts\u query ($q){
$tax\u query= (array) $q->get (\
$tax_query[]= array(
\
\
\
Operator = > none
);
$q->set (‘tax\u query’, $tax\u query);
}Male
Therefore, furniture and unclassified products should not be displayed when this code is entered. To remove a category, use the code snippet shown above. You can remove categories from a given category, not just products. End with the idea of hiding woocommerce categories in store pages. In the function of woocommerce store pages, hiding categories is very important to make store pages easy to use and manage. Helps you easily configure products and categorize them into the correct categories. It is also suitable for customers who can choose the products they need, thus improving customer satisfaction and increasing traffic, sales and conversion. The
Do you know that the data will be beautiful? Wpdatatables can do this. #The WordPress plug-in is used to create interactive tables and charts for a reason. In the wild, the actual example of wpdatatables and the following are really easy. You can publish tabular data to posts or pages that provide configuration and customization, and it is not only beautiful, but also practical. You can create a large table with up to millions of rows, use advanced filtering and search, or edit it in the field. Yes, but I like excel so much that it is not available on the website. Yes, there is. You can use conditional formats, such as Excel or Google spreadsheets. Did I say I could use your data to make charts? And that’s only a small part. There are many other functions. If you read this article about hiding the woocommerce category on the shopping page, you should check it out to learn how to set up woocommerce related products. In addition, the method of changing the quantity of woocommerce products per page, the method of exporting woocommerce orders, the variant of woocommerce products, and wooco
I also wrote some related topics, such as e-commerce engagement plug-ins, woocommerce redirection after check-out, woocommerce test mode setting methods, woocommerce group products, etc. Woocommerce variable products and the best woocommerce add-on product options.