A sidebar, in a graphical user interface, simply means a narrow vertical area that is located alongside the main display area, containing related information or navigation options.

It can be anything, from advertisements to recent posts.

Or, to put in this way, a sidebar in WordPress is that widget-ready area used to display information.

It isn’t necessary to be a vertical column on aside, it can take various shapes. It can be a rectangle above or below the content area, etc.

See below an example:

layout-design-webpage-example
This is how a WordPress theme which is widget-ready looks like.

The role of a sidebar

When it comes to the layout design of a WordPress theme, it’s very important to establish from the beginning all the widget areas. If the theme isn’t widget-ready, you can’t expect to have sidebars.

How can you tell if a theme is widget-ready?

The answer is simple!

You either search for this information on the preview page of that theme, or you can ask the web developer if his theme is widget-ready.

Do all of these, before you purchase the theme.

Don’t rush it!

wordpress-sidebar-question
This question we're received on our "Q&A" page. Let's solve it!

Let’s say your WordPress theme is widget-ready, and you want to show the sidebar only to the author of the post.

Can it be done?

Sure!

To show your sidebar only to the author, you need to first locate the get_sidebar() code in your theme files.

Usually, this code can be found in the root of your theme, in the file single.php.

Then replace the code get_sidebar() with this one:

  1. function show_sidebar_only_to_author(){    
  2.  global $post;
  3.  $page_id = get_queried_object_id();
  4.  $user_id = get_current_user_id();  
  5.  $author_id = get_post_field( 'post_author', $page_id );
  6.    if ( $user_id == $author_id ) {
  7.    get_sidebar();   
  8.  }
  9. }
  10. add_action( 'get_footer', 'show_sidebar_only_to_author' );

And you’re done.

In case you ever have any questions related to WordPress themes, plugins, or general topics, we created a page where you can pop your questions.

I call it the “Q&A” WordPress page.

the-Q&a-wordpress-page-from-wowlayers

The purpose of the page is to help as many as we can.

Feel free to ask us anything.

If you find this interesting, share it with others.

Helping you, to help me