How To Add Custom Sidebar To Your Wp Theme




You Are Currently Viewing This Forum As A GUEST!.
You Are Restricted In Some Area
Login Or Register
To Have Full Access To The Forum .


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

How To Add Custom Sidebar To Your Wp Theme
(2138 Views )
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.

Quote
Tanks

Quote
nice one

never say never believe
Quote

Share This Post To The World



You Are Currently Viewing This Forum As A GUEST!.
You Are Restricted In Some Area
Login Or Register
To Have Full Access To The Forum .



Did You Want Latest Nigerian Songs? Click HERE



Possibly Related Threads...
Thread
Should Peter And Paul Re-unite? Lets Hear Your Opinion
How To Pay Dstv Subscripti Bills With Kongapay App Using Your Phone
[script] Add All Friends To Facebook Group In One Click – In 20 Seconds
TUTORIAL: Here’s What To Do When Your Smartphone Falls Into Water
FIXED: Stop Your Friends From Changing Your Whatsapp Group Names With New Admin Tools
How To Increase The Overall Speed And Performance Of Your Android Device
HOT: How To Secure Your Website

Wapforum.com.ng Is The Next Big Hits Online Public Forum In Nigeria




Users browsing this thread: 1 Guest(s)




Copyright © 2018 Wapforum.Com.Ng
Owned by Flexible


Powered by MyBB.