Creating custom widget areas when using a theme which don’t offer hooks isn’t difficult. You’ll need to add code to your parent themes single.php file which is not best practice.
If you can, copy the single.php template file from your parent theme and place it in a child theme.
In this tutorial, we’ll add an after post widget area on all single posts using the Twenty Thirteen default theme for WordPress.
You can use this tutorial and code snippets to add a new widget to any theme which doesn’t provide hooks.
To do this we need to do 2 things:
- Register a widget which displays the custom widget area which you’ll see when you go to Appearance > Widgets from your wordPress dashboard.
- Paste the code in your child themes single.php file to display the widgets content after the content on all single posts.
Note: Please don’t use this code if you’re using the Genesis theme framework or another premium theme which uses custom hooks.
Here’s the code and tutorial for creating a widget area after single posts in Genesis child themes which you can modify if your theme uses different hooks.
Register After Post Widget
Paste this code at the end of your child themes functions.php file
Here’s what you’ll see now when you go to your widgets page:
Output Widget in Single Posts Template
Paste this code in your child themes single.php file where you want to output your widgets content.
Here’s a screen shot of what the single.php file looks like before you copy the code into your Twenty Thirteen child theme.
Before Code Pasted- Click Image To Enlarge
After Code Pasted- Click Image To Enlarge
Styling After Post Widget
Simply add or delete any of these CSS properties to customize the appearance and styling of your widgets content.
Paste the code at the end of your child themes style.css file.
I know there’s different methods you can use to register a new widget and display it in your child themes template. This is one way to add a widget area below all your single posts.
Don’t forget the Twenty Twelve theme is full width unless you add content to the sidebar widget areas. You may need to modify the padding and other values so whatever you place in your new custom widget area looks good.Subscribe for new Genesis Tutorials