-3

How can I make my own custom sidebar for my blog when my theme does not provide an option to add a custom sidebar?

5
  • You need to change the theme code to have that widget area. – bravokeyl Aug 18 '16 at 7:33
  • how can i do that? without knowing php ? – gad Aug 18 '16 at 7:35
  • Well you need to know php to do that else find out a plugin which does that or find out someone who can do this for you. – bravokeyl Aug 18 '16 at 7:36
  • is there somewhere this kind of plugin? – gad Aug 18 '16 at 7:58
  • 2
    If your theme doesn't support sidebars you'll either need to find a new theme or contact a developer. What you're asking is to change the entire layout of your sites blog section to support something it doesn't support. This falls out of scope for a single question as being too broad. – Howdy_McGee Aug 18 '16 at 15:46
1

You need to register the widget area in your themes functions.php file. Your code should look something like this.

//register the widget area
function your_function_name() {
     register_sidebar(array(
         'name' => esc_html__('Sidebar', 'your_theme_name'),
         'id' => 'sidebar-1',
         'description' => esc_html__('Add widgets here.', 'your_theme_name'),
         'before_widget' => '<section id="%1$s" class="widget %2$s">',
         'after_widget' => '</section>',
         'before_title' => '<h2 class="widget-title">',
         'after_title' => '</h2>',
     )); } 

add_action('widgets_init', 'your_function_name'); //This hooks into WordPress wigets_init function.

You can learn more about widgetizing themes here. Another great place to learn and understand hooks, actions and filters is this site, it really helped me out. I hope this all helps. =)

0

You should also create a sidebar.php template in your theme, embed the first code shared by @user53340 the add <?php get_sidebar(); ?> anywhere you want the sidebar to show, you should also float the css class you used to wrap it to left or right just as you like.

Not the answer you're looking for? Browse other questions tagged or ask your own question.