In this tutorial I will show a correct way of removing product prices from single product pages and shop page (product archives).
There are plenty of tutorials out there that recommend you to use
woocommerce_get_price_html hook which is totally wrong, because that hook is intended to edit the HTML of the price element. We are not going to hide prices with CSS as well.
WooCommerce connects product prices to hooks:
woocommerce_after_shop_loop_item_title– for product archive pages,
woocommerce_single_product_summary– for single product pages.
So all we need to do is to disconnect price displaying functions from these hooks!
There are already a couple tutorials on this website related to product sorting, you can read for example, how to change a default sorting order, how to completely remove it or how to add a custom sorting option.
Today we are going to go even further and add an option to sort products in random order and retain it during pagination.
First things first, let’s add a new sorting option. There is another tutorial about that, so you can read more if you want. Right now we are going to do it with
woocommerce_catalog_orderby filter hook.
In this tutorial I will show you how to completely remove this dropdown from the shop page and product archives:
That’s the result we are going to achieve:
And we are not hiding it with CSS by the way!
The default WooCommerce sorting is by “menu order”, which means manually and if a manual product order is not set, the product are going to be displayed alphabetically.
Before we continue, let me show you how to sort WooCommerce products manually, maybe it is just what you need.
Go to WordPress admin, All Products page, and there click Sorting tab. After that just use drag and drop.
This is a complete tutorial about product sorting options in WooCommerce.
You can find product sorting dropdown on the shop page or in the product archives.
But the thing is that you can not just remove any link that easy. The problems may appear if you would like to remove “Dashboard” from my account menu.
So our goal for this tutorial is not only to remove a “Dashboard” menu link but also to perform a redirect to the next menu link. It is “Orders” by default.
I hope it is crystal clear why we need a redirect. Let’s imagine a situation when a customer signs in to your WooCommerce website. What My Account page will be displayed by default? Right. Besides,
wp_get_page_permalink( 'myaccount' ) is probably used in your theme files, this function also sends users to the Dashboard page! So I think it is not enough just to redirect users after signing in, we should redirect them every time they are trying to access the Dashboard.
In this tutorial I will introduce two ways of how to remove “Showing X of X results” or “Showing the single result” text from WooCommerce product archive pages.
Example of what we going to remove is on the screenshot below.