[-]
Tags
to sidebar add your custom wp how theme


Hi Guest, kindly Login Or Register To Unlock More Advanced Features In Wapforum


How To Add Custom Sidebar To Your Wp Theme
(5k )
#1
How to Add a Custom Sidebar to WordPress Themes
Sidebars allow you display widgets inside your theme.

And yes, despite the name, you can use "sidebars" to display widgets anywhere you want.

By default, themes come with at least one sidebar.

In this post, I'm going share with you a quick way to add a custom sidebar to your WordPress theme.

Step #1. Create a child theme

If you’re using a custom theme, skip this step. However if you’re using a theme maintained by someone else that may be updated in future, I recommend you create a child theme to leave the original intact.

Install the Child Theme Configurator plugin and copy the required template files such as single.php and page.php into the child theme. The step 4 explains this part.

Step #2. Edit the functions.php file

Go to Appearance > Editor > functions.php.
Choose functions.php from your child theme.
custom sidebar wordpress

Add this code into functions.php in order to register your custom sidebar:

function my_custom_sidebar() {
register_sidebar(
array (
'name' => __( 'Custom', 'your-theme-domain' ),
'id' => 'custom-side-bar',
'description' => __( 'Custom Sidebar', 'your-theme-domain' ),
'before_widget' => '
',
'after_widget' => "
",
'before_title' => '

',
'after_title' => '

',
)
);
}
add_action( 'widgets_init', 'my_custom_sidebar' );
Click the "Update file" button when you’re done.
Step #3. Edit the template files

I want to render the custom sidebar in single posts only, so I'll edit the "Single post" file.




I placed the code above in the location where I want the sidebar to be visible, then I save the changes.

custom sidebar wordpress

Step #4. Check the end result

Go to Appearance > Widgets to see if the new sidebar available.
Add the widgets you need.
custom sidebar wordpress

Preview a single post to see your sidebar in action. The widgets loads as expected in our custom sidebar. Note, some CSS design tweaks will probably be required.


#2
Tanks


#3
nice one


Share This Post To The World






Users browsing this thread: 1 Guest(s)
Goto First Post In This Thread



Possibly Related Threads...
Thread Author Replies Views Last Post
  How To Retrieve Your Nin Without Visiting Their Office pixblog 0 84 11-01-2020, 04:06 PM
Last Post: pixblog
Question NEW! [Discussion Time] What If You Die Today, Who Will Inherit Or Take Over Your Website?? flexible 2 763 22-11-2019, 11:46 PM
Last Post: kharlm
  MUST READ: Catch Up With Your National Daily Kelvztech1 0 175 22-11-2019, 11:33 PM
Last Post: Kelvztech1
  HOT: SeekHype.com.ng WordPress Theme Shared By Razicoded (Old Version) razicoded 3 1.2k 16-10-2019, 05:39 PM
Last Post: jayarambro
  MUST READ: Top 15 Forum Site In Nigeria Is Coming Kindly Drop Your Forum Liink olamideoladesino 18 13.8k 03-09-2019, 07:48 PM
Last Post: lordbright
  NEW! Create Paypal Account That Receives Payment In Nigeria To Your Bank Account OgEmmex 0 469 29-06-2019, 01:24 PM
Last Post: OgEmmex
  Boss International - Changing Your Financial Story Bigga 1 791 26-06-2019, 06:08 AM
Last Post: harshak99




Advertisement