• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WordPress Tips, Code Snippets, and How To Tutorials

  • Home
  • Blog
  • Tips
  • Snippets
  • Tutorials
  • Contact

Categories

How to hide the product count in category list view on WooCommerce on WordPress

November 12, 2019 by admin Leave a Comment

When you use WooCommerce for the ecommerce on your WordPress website you may want to hide the product count in the category list view on the website. To do that without a plugin you can then add this code to your functions.php file. We recommend that you backup your WordPress website before you make updates the file on there.

Hide WooCommerce product count on category list view

/**
 * Hide WooCommerce product count on category list view
 *
 * @author WPSnacks.com
 * @link https://wpsnacks.com/
 */
function woo_remove_category_products_count() {
	return;
}
add_filter( 'woocommerce_subcategory_count_html', 'woo_remove_category_products_count' );

Now if that works for you it would remove or hide the product count on category list view on WooCommerce on your WordPress website on there.

If you like this then you should look up more of our WordPress Tips Code Snippets and Tutorials.

Disclosure: There are affiliate links on posts and throughout the website and if you use the links to make a purchase we may earn a commission from it. We link to these companies and their products because of the quality of the companies and not because of the commission we may receive from it.

Disclaimer: The information contained in this website is for general information purposes only and in no event will this website or its owners be liable for any losses or damages associated with your use of our website or content. We recommend that you make a backup of your website before you make updates to it. Click here to see our full Disclaimer.

Filed Under: Code Snippets Tagged With: Categories, Functions.php, WooCommerce

How to find the id of one of the categories on the blog of your WordPress website

October 29, 2019 by admin Leave a Comment

On your WordPress website you may want to know the id number of one of the categories on the blog of your website. You may want to do something like remove one category from the blog on your front page and having that id number may help with that.

  1. From the WordPress admin left menu click on posts > categories
  2. Hover your mouse over the title of the category that you want the id for
  3. Look in the lower left corner of your internet browser
  4. You should see a url listed
  5. That url will likely look like https://yourdomain/wp-admin/term.php?taxonomy=category&tag_ID=# with more text in the link where the # is the category id

Now that you have that id number you can use that if needed in your code on there like in the post linked at the top of this post on here.

If you like this then you should look up more of our WordPress Tips Code Snippets and Tutorials.

Disclosure: There are affiliate links on posts and throughout the website and if you use the links to make a purchase we may earn a commission from it. We link to these companies and their products because of the quality of the companies and not because of the commission we may receive from it.

Disclaimer: The information contained in this website is for general information purposes only and in no event will this website or its owners be liable for any losses or damages associated with your use of our website or content. We recommend that you make a backup of your website before you make updates to it. Click here to see our full Disclaimer.

Filed Under: WordPress Tips Tagged With: Categories, Links, WordPress Admin

How to exclude or remove the posts of one category from WordPress blog feed on front home page

October 29, 2019 by admin Leave a Comment

If you are using WordPress for your website you may want to exclude or remove the posts from one category of your blog from the blog feed on your website on the front page there. You can then add this code to your functions.php file. You may want to backup your WordPress website before you make updates to it on there.

/**
 * remove category from blog feed on front page
 *
 * @author WPSnacks.com
 * @link https://www.wpsnacks.com
 */
function remove_category_from_blog( $query ) {
    if( $query->is_main_query() && $query->is_home() ) {
        $query->set( 'cat', '-#' );
    }
}
add_action( 'pre_get_posts', 'remove_category_from_blog' );

You can then replace the # with the id number of the category you want to remove from it. This post may help you to find the category id number on there. Now if that works for you it would remove that category from the blog feed on the front page of your WordPress website on there.

If you like this then you should look up more of our WordPress Tips Code Snippets and Tutorials.

Disclosure: There are affiliate links on posts and throughout the website and if you use the links to make a purchase we may earn a commission from it. We link to these companies and their products because of the quality of the companies and not because of the commission we may receive from it.

Disclaimer: The information contained in this website is for general information purposes only and in no event will this website or its owners be liable for any losses or damages associated with your use of our website or content. We recommend that you make a backup of your website before you make updates to it. Click here to see our full Disclaimer.

Filed Under: Code Snippets Tagged With: Blog, Categories, Functions.php, Templates, WordPress Admin, WordPress Theme

How to exclude a category from the loop on your home page

March 9, 2015 by admin 1 Comment

Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to exclude one or more categories from the loop on your home page.
[Read more…] about How to exclude a category from the loop on your home page

If you like this then you should look up more of our WordPress Tips Code Snippets and Tutorials.

Disclosure: There are affiliate links on posts and throughout the website and if you use the links to make a purchase we may earn a commission from it. We link to these companies and their products because of the quality of the companies and not because of the commission we may receive from it.

Disclaimer: The information contained in this website is for general information purposes only and in no event will this website or its owners be liable for any losses or damages associated with your use of our website or content. We recommend that you make a backup of your website before you make updates to it. Click here to see our full Disclaimer.

Filed Under: Code Snippets Tagged With: Categories, Functions.php, Home Page, WordPress Loop

Primary Sidebar

Hey, We Deliver... Anywhere!

Enter Email Address below to receive our snacks via email:

Join Over 1200 Readers!

Jump To A Random WordPress Tip

Copyright © 2019 • wpsnacks.com