Today I spent hours trying to figure out the best way to add keyword meta tags to product category pages in Woocommerce without adding yet another plugin to slow my site down. Here is the final solution I ended up doing to add meta keyword tags to product category page in WordPress.
Product categories use a special WooCommerce page template located in wp-content/plugins/woocommerce/templates/ in a file named archive-product.php. If you open that file you’ll notice the get_header WordPress function looks like:
Okay so if you understand the WordPress get_header function you’ll know this indicates that there is a special header file involved here. The get_header function appends what’s in the parenthesis to the prefix: “header-” then appends “.php” to the end in order to create the file name of the header file for the template it’s called within. That means in this case it points to a file named “header-shop.php”. Therfore the first thing you need to do is check your active theme directory for a file named header-shop.php. Most themes do not have this file and by default, it calls the header.php file if header-shop.php does not exist. For details and technical help with e commerce, there’s more on this website for all levels of expertise. Just keep a cool head and you will succeed, the information is out there, you just need to find it and use it.
Edit or Add header-shop.php File:
If you found the header-shop.php file, great, simply edit it to your needs and done. In my case if I had found one, which I didn’t, all I would have had to do would be to add meta tags under the title tag in the head section of the file.
If you did not find header-shop.php, then make a copy of header.php and name it header-shop.php and upload it to the same directory as header.php. Then you can edit header-shop.php to only make changes to pages that use that header tempalte such as the product category pages. In my case, I wanted to add custom meta tags to the product category pages, so I added the following inside of the head tags in header-shop.php and uploaded it to the current theme folder:
<meta name=”description” content=”insert your custom product category description here.” />
<meta name=”keywords” content=”your keywords go here, separate with commas” />