mjuanstudio
Member
Posted 11 months ago #
I am trying to add an additional sidebar (with widgets) to my site which already has two other sidebars. I have gone through numerous instructions that I have found via WordPress and have been unable to add a new sidebar.
I followed these directions:
New way of adding sidebars
I got up to where it states "you have to create a custom sidebar-file under the name sidebar-custom.php."
The next step would be to see my sidebar under my appearance tab but it is not there.
Help!
We'll need to see your actual code, in order to help.
mjuanstudio
Member
Posted 11 months ago #
What part of the code do you need to see?
The code you're using to add the additional sidebar.
mjuanstudio
Member
Posted 11 months ago #
This is in my widgets.php file
[Code moderated as per Forum Rules - please use the Pastebin]
That is Widget-registering code, not dynamic sidebar-registering code.
Can you post the code you're using to register your sidebar?
(Also: forum rules require any code longer than about 10 lines to be added to a Pastebin, and linked in the topic.)
mjuanstudio
Member
Posted 11 months ago #
That is the only code that I have put in thus far. I stopped at this instruction because i did not see my sidebar listed under my widgets. I am unsure what my next step would be.
None of the code you added actually registers a sidebar.
You need to register a sidebar in order for it to appear.
See here: http://codex.wordpress.org/Function_Reference/register_sidebar
mjuanstudio
Member
Posted 11 months ago #
This is what I added in the widgets.php file:
register_sidebar(array(
'name' => 'custom',
'description' => 'Widgets in this area will be shown on the right-hand side.',
'before_title' => '',
'after_title' => ''
));
<?php if ( function_exists ('register_sidebar')) {
register_sidebar ('custom');
} ?>
Take out this bit:
<?php if ( function_exists ('register_sidebar')) {
register_sidebar ('custom');
} ?>
mjuanstudio
Member
Posted 11 months ago #
So then where will I see my new sidebar. RIght now it is still pulling the old one even though I have named it 'custom' in my index file.
You need to hook that register_sidebar() call into the widgets_init hook.
mjuanstudio
Member
Posted 11 months ago #
Im sorry. Looking and cant find the widgets_init hook. Where would I find it?
You need to do something like this:
function mytheme_register_sidebars() {
register_sidebar(array(
'name' => 'custom',
'description' => 'Widgets in this area will be shown on the right-hand side.',
'before_title' => '',
'after_title' => ''
));
}
add_action( 'widgets_init', 'mytheme_register_sidebars' );
mjuanstudio
Member
Posted 11 months ago #
I customized it:
function sdttheme_register_sidebars() {
register_sidebar(array(
'name' => 'custom',
'description' => 'Widgets in this area will be shown on the right-hand side.',
'before_title' => '',
'after_title' => ''
));
}
add_action( 'widgets_init', 'sdttheme_register_sidebars' );
Is this correct? What would be my next step from here/
Now, go to Dashboard -> Appearance -> Widgets
Do you see your Sidebar listed?
mjuanstudio
Member
Posted 11 months ago #
Can you move that function and add_action call out of your widgets.php file, and directly into your functions.php file, just for testing?
Oh, wait: try hooking into 'after_setup_theme' rather than 'widgets_init'.
i.e.:
add_action( 'after_setup_theme', 'sdttheme_register_sidebars' );
mjuanstudio
Member
Posted 11 months ago #
Actually putting it in the Functions file worked! I see it now in my widgets!
mjuanstudio
Member
Posted 11 months ago #
Great! So now you just need to add the dynamic sidebar somewhere in your template, and you're good to go.
I installed the WP Big City theme, now I want the move the sidebar from the right to the left.
Please help me.
Thx.