Tag - Wordpress

Woocommerce Custom Sidebar on Shop Page (Without using a plugin)
Make Money with WordPress and Google Adsense

Woocommerce Custom Sidebar on Shop Page (Without using a plugin)

After working with Woocommerce recently, I discovered that out of the box, Woocommerce displays the main blog sidebar on the shop pages.

Since the main WordPress sidebar contains blog-related widgets by default, this is clearly far from ideal.

I wanted instead for the Woocommerce shop page to have it’s own sidebar, with widgets related to searching and filtering products, not posts.

After digging through the code looking for a clean solution, I found that the solution is easy, and it’s as clean as copying a single template file and making a minor edit.

1. Create your new Widget Area

In your website’s filesystem (using your OS’s file explorer if it’s local to your machine, or via SFTP if it’s a remote webserver), navigate to your theme’s directory (/wp-content/themes/THEMENAME/) and edit the functions.php file.

At the end of the file, add the following code:

function custom_widgets_init() {
			'name'          => esc_html__( 'Shop Sidebar', 'sirius' ),
			'id'            => 'sidebar-shop',
			'description'   => esc_html__( 'Add widgets here.', 'sirius' ),
			'before_widget' => '<section id="%1$s" class="widget %2$s">',
			'after_widget'  => '</section>',
			'before_title'  => '<h4>',
			'after_title'   => '</h4>',
add_action( 'widgets_init', 'custom_widgets_init' );

If you already have a function attached to the widgets_init action, you can just add the call to register_sidebar into it.

2. Add widgets to your new widget area

Drag some widgets into your new widget area. Here are a few relevant Woocommerce widgets you might find appropriate:

  • Product Search
  • Filter Products by Attribute
  • Product Categories
  • Product Tag Cloud
  • Products By Rating
  • Recent Viewed Products

Adding widgets to the widget area


3. Create a custom shop sidebar template

Now we’re ready to create the template file which will output the new sidebar on the frontend of your website.

In your website’s filesystem (using your OS’s file explorer if it’s local to your machine, or via SFTP if it’s a remote webserver), navigate to your theme’s directory (/wp-content/themes/THEMENAME/) and copy the sidebar.php file to sidebar-shop.php

Edit the new sidebar-shop.php template using your favourite text editor and change any references to ‘sidebar-1’ to ‘sidebar-shop’

Here is the content from my sidebar-shop.php file.

 * The sidebar containing the main widget area
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 * @package Sirius
if ( ! is_active_sidebar( 'sidebar-shop' ) ) {
<aside id="secondary" class="widget-area">
	<?php dynamic_sidebar( 'sidebar-shop' ); ?>
</aside><!-- #secondary -->

And you’re done!

Now when you visit the shop page on the frontend of your website, you should see your shop sidebar instead of the main sidebar which is displayed when visiting the rest of your site.

If that was helpful, I’d really appreciate you taking the time to share this post on social media. You may also like to check out some of my other Woocommerce and WordPress related posts.

Make Money with WordPress and Google Adsense

ChartThere are many different methods employed by people to make money online. And there are even more people claiming to be making thousands each month online, each only happy to share their secret with you if you just buy their ebook or join their premium subscription service.
Most of these ‘methods’ don’t work. Some of them used to, but now the markets are so saturated that the only people making money from them are the guys selling the spammy get-rich-quick products. As the old adage goes, during the California gold rush, the only people who made any money were the ones selling the picks!

There is one tried and true method to making money online however. A method that is based on a solid business model which has been around for decades in the print industry. Create compelling, useful content which people will want to come and read, and then sell advertising space.

Become a Blogger

The internet makes this method so much simpler these days. No longer do you have to go through a publisher to have your magazine published, then have a distributor deliver your magazine across the country. It’s as simple as setting up a blog, whacking some ads on there and writing content each day, or even just each week.

The hardest part of writing a blog is staying disciplined enough to write long, engaging articles consistently for weeks, months and even years without procrastinating or getting bored. I, along with many other bloggers find that to be one of the hardest parts of writing an online blog. Lack of persistence is the number one reason why most bloggers fail within their first year.

Choose your Subject

This step is incredibly important. If you want to still be able to write content for your blog six months down the line without wanting to claw your own eyeballs out, choose a topic that you are passionate about. A topic that you know intimately well, so that you have a lot of knowledge or useful opinions that you can share. Spend days, or even weeks on choosing the right subject area as this is probably the most important decision you will make and could be the difference between success and failure.

Set up a Blog

If you think you have got what it takes to become a successful blogger, then you need to start by purchasing web hosting. Nothing special, shared web hosting will be sufficient. I personally recommend eUKhost as they are affordable and pretty reliable. Plus their customer service is great.

As your blogging platform, WordPress is probably the best (certainly most popular) choice. If you’re technically challenged, hire a freelance specialist to do this for you using a site such as Elance. I strongly recommend reading my guide to hiring on elance first.

While you’re building your WordPress blog, create an account with Google Adsense and be sure to install an Adsense plugin for WordPress to create ads on your site. There are loads of other useful WordPress plugins, so have a look through the Wordress plugin directory for any that you think might add value to your site.

Start Blogging!

I recommend that you write an informative, well researched blog post at least every week. If you can, write one every day. Carefully proof read what you’ve done and spend time getting it just right. Would you return to a blog littered with spelling and grammatical errors?

Don’t expect to make money overnight. It can take months or even years to start generating revenue from your blog. The important thing is not to be dissuaded. Keep at it. Keep focused and keep writing good content. It is inevitable that eventually your traffic will increase and it will reach a tipping point where suddenly you will see an exponential growth of traffic.

Keep learning, improve your writing, working on your website and success is inevitable.

Good luck and happy blogging!

Copyright © 2018. Created by Hayden Kibble.