Earlier in the afternoon, I had asked for a solution on how to echo different sidebars on different category pages of Wordpress which was solved. Now the problem which I am facing is that there's a continuous '1' being displayed under the sidebar on all the category pages. However, this isn't happening when I switch back to the old code which was displaying only one sidebar on all the category pages. Here's the code which was originally inside the sidebar.php file and which was echoing only one sidebar on all the pages:
<?php if ( is_active_sidebar( 'main_sidebar' ) ) : ?>
<div id="main_sidebar" class="widget-area">
<?php dynamic_sidebar( 'main_sidebar' ); ?>
</div><!-- #first_sidebar .widget-area -->
<?php endif; ?>
And this is the modified code which I have put inside the sidebar.php file which is echoing different sidebars on different category pages:
<?php if ( is_active_sidebar( "main_sidebar" ) ) : ?>
<div id="main_sidebar" class="widget-area">
<?php
if ( is_category( '7' )) {
echo dynamic_sidebar( 'category_fashion' );
}
elseif ( is_category( '1' )) {
echo dynamic_sidebar( 'category_music' );
}
elseif ( is_category( '5' )) {
echo dynamic_sidebar( 'category_tastemakers' );
}
elseif ( is_category( '11' )) {
echo dynamic_sidebar( 'category_film' );
}
elseif ( is_category( '9' )) {
echo dynamic_sidebar( 'category_model' );
}
elseif ( is_category( '6' )) {
echo dynamic_sidebar( 'category_sports' );
}
elseif ( is_category( '8' )) {
echo dynamic_sidebar( 'category_round' );
}
elseif ( is_category( '10' )) {
echo dynamic_sidebar( 'category_cool' );
}
else
{
echo dynamic_sidebar( 'main_sidebar' );
}
?>
</div><!-- #first_sidebar .widget-area -->
<?php endif; ?>
When I use the original code, the number '1' doesn't appear under the sidebar but when I switch to the code which I've modified, the number '1' starts to appear under the sidebar on all the pages. This behavior can be seen by going to this link: http://ignoremusic.com/category/sports/
I have also checked the archive.php file as well as the functions.php file but nothing seems to be wrong. Here's the part of the code which I've put inside the functions.php file to register the sidebars:
/** SIDEBARS ******************************************************************/
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name'=>'sidebar home left',
'id' => 'homeleft_sidebar',
'description' => __( 'sidebar on homepage, left', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'Category: Tastemakers',
'id' => 'category_tastemakers',
'description' => __( 'sidebar on tastemakers category', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'Category: Film',
'id' => 'category_film',
'description' => __( 'sidebar on film category', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'Category: Fashion',
'id' => 'category_fashion',
'description' => __( 'sidebar on fashion category', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'Category: Model Citizens',
'id' => 'category_model',
'description' => __( 'sidebar on model citizens category', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'Category: Sports',
'id' => 'category_sports',
'description' => __( 'sidebar on sports category', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'Category: Round Table',
'id' => 'category_round',
'description' => __( 'sidebar on round table category', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'Category: Cool Stuff',
'id' => 'category_cool',
'description' => __( 'sidebar on cool stuff category', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'Category: Music',
'id' => 'category_music',
'description' => __( 'sidebar on music category', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'sidebar home right',
'id' => 'homeright_sidebar',
'description' => __( 'sidebar on homepage, right', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'main sidebar',
'id' => 'main_sidebar',
'description' => __( 'main sidebar', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'tour dates sidebar',
'id' => 'tour_sidebar',
'description' => __( 'sidebar on tour dates page', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'contact sidebar',
'id' => 'contact_sidebar',
'description' => __( 'sidebar on contact page', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'sidebar footer 1',
'id' => 'sidebarf1',
'description' => __( 'first sidebar in footer', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'sidebar footer 2',
'id' => 'sidebarf2',
'description' => __( 'second sidebar in footer', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'sidebar footer 3',
'id' => 'sidebarf3',
'description' => __( 'third sidebar in footer', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
register_sidebar(array(
'name'=>'sidebar footer 4',
'id' => 'sidebarf4',
'description' => __( 'fourth sidebar in footer', 'gxg_textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>', ));
}
And this is the code inside the archives.php file which is echoing the sidebar:
<div id="sidebar" class="grid_3">
<?php get_sidebar(); ?>
</div><!-- #sidebar-->
I tried searching for the problem on the internet but couldn't find anything so I look forward to hear from you guys. Thank you.
According to https://codex.wordpress.org/Function_Reference/dynamic_sidebar it should be
dynamic_sidebar( 'category_fashion' );
instead of echo dynamic_sidebar( 'category_fashion' );
The function probably returns true; echo takes a string; true->string=1, therefore the additional 1.
Superfluous echo, caused by confusion, caused by silly Wordpress functions that print things rather than returning them.
In your case, the following is at fault:
<?php echo dynamic_sidebar( 'category_fashion' ); ?>
Contrast with your earlier and correct usage:
<?php dynamic_sidebar( 'main_sidebar' ); ?>
Related
I have imported a theme and all is working well with Wordpress. However, I am trying to add a widget into the footer.php but for some reason this is not displaying.
My footer.php is as follows:-
<?php get_sidebar('footer_widget'); ?>
And I have added this into functions.php too
function bauhaus_arphabet_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'sidebar', 'bauhaus' ),
'id' => 'bauhaus_sidebar',
'before_widget' => '<div id="%1$s" class="widget sidebar_widget %2$s">',
'after_widget' => '</div>',
'description' => esc_html__( 'blog sidebar', 'bauhaus' ),
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Footer', 'bauhaus' ),
'id' => 'footer_widget',
'before_widget' => '<div id="%1$s" class="widget footer_widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>'
));
}
Does anyone have any idea why this is not displaying?
Thank you in advance,
Scott
Replace the code with :
<?php dynamic_sidebar( 'footer_widget' ); ?>
I'm getting a error500 on my page tolkeuddannelsen.dk. Through the error log I can se that its line 93-185 in my themes function.php that is causing the trouble. This is what my webhost says:
Backend fatal error: PHP Fatal error: Cannot redeclare thim_widgets_inits() (previously declared in /var/www/www.tolkeuddannelsen.dk/www/functions.php:93) in /var/www/www.tolkeuddannelsen.dk/www/wp-content/themes/elearningwp/functions.php on line 185\n, referer: http://tolkeuddannelsen.dk/
The code in these lines looks like this.
function thim_widgets_inits() {
register_sidebar( array(
'name' => __( 'Sidebar 1', 'thim' ),
'id' => 'sidebar-1',
'description' => 'Left Sidebar',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
// register_sidebar( array(
// 'name' => __( 'Sidebar 2', 'thim' ),
// 'id' => 'sidebar-2',
// 'description' => 'Right Sidebar',
// 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
// 'after_widget' => '</aside>',
// 'before_title' => '<h4 class="widget-title">',
// 'after_title' => '</h4>',
// ) );
register_sidebar( array(
'name' => 'Top Drawer',
'id' => 'drawer_top',
'description' => __( 'Drawer Top', 'thim' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => __( 'Offcanvas', 'thim' ),
'id' => 'offcanvas_sidebar',
'description' => 'Drawer Right',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => 'Menu Right',
'id' => 'menu_right',
'description' => __( 'Menu Right', 'thim' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => 'Footer',
'id' => 'footer',
'description' => __( 'Footer Sidebar', 'thim' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s footer_widget">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => 'Copyright',
'id' => 'copyright',
'description' => __( 'Copyright', 'thim' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => __( 'Sidebar Shop', 'thim' ),
'id' => 'shop',
'description' => 'Shop Sidebar',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
if ( class_exists( 'LearnPress' ) ) {
register_sidebar( array(
'name' => 'Top Sidebar Courses',
'id' => 'top_sidebar_courses',
'description' => __( 'Top Sidebar Courses', 'thim' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => 'Sidebar Courses',
'id' => 'sidebar_courses',
'description' => __( 'Sidebar Courses', 'thim' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
}
}
Can anyone help me fix this problem? Thanks!
This is because you are redeclaring your function which is already declared.
Use this one :
function thim_widgets_inits_child() {
register_sidebar( array(
'name' => __( 'Sidebar 1', 'thim' ),
'id' => 'sidebar-1',
'description' => 'Left Sidebar',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
// register_sidebar( array(
// 'name' => __( 'Sidebar 2', 'thim' ),
// 'id' => 'sidebar-2',
// 'description' => 'Right Sidebar',
// 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
// 'after_widget' => '</aside>',
// 'before_title' => '<h4 class="widget-title">',
// 'after_title' => '</h4>',
// ) );
register_sidebar( array(
'name' => 'Top Drawer',
'id' => 'drawer_top',
'description' => __( 'Drawer Top', 'thim' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => __( 'Offcanvas', 'thim' ),
'id' => 'offcanvas_sidebar',
'description' => 'Drawer Right',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => 'Menu Right',
'id' => 'menu_right',
'description' => __( 'Menu Right', 'thim' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => 'Footer',
'id' => 'footer',
'description' => __( 'Footer Sidebar', 'thim' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s footer_widget">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => 'Copyright',
'id' => 'copyright',
'description' => __( 'Copyright', 'thim' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => __( 'Sidebar Shop', 'thim' ),
'id' => 'shop',
'description' => 'Shop Sidebar',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
if ( class_exists( 'LearnPress' ) ) {
register_sidebar( array(
'name' => 'Top Sidebar Courses',
'id' => 'top_sidebar_courses',
'description' => __( 'Top Sidebar Courses', 'thim' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => 'Sidebar Courses',
'id' => 'sidebar_courses',
'description' => __( 'Sidebar Courses', 'thim' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
}
}
After that use action
add_action('init','thim_widgets_inits_child');
Wordpress can do this:
function _tk_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', '_tk' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', '_tk_widgets_init' );
This would produce something like this:
<aside>
<h3></h3>
BODY
</aside>
What I need to be able to do is end up with:
<aside>
<h3></h3>
<div class="anotherBlock">BODY</div>
</aside>
Is this possible?
Solved it usig what was already there:
register_sidebar( array(
'name' => __( 'Sidebar', '_tk' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3><div class="mainWidgetBody">',
'after_widget' => '</div></aside>',
) );
I want to change the H1 to H2 in the functions.php from my wordpress site.
I have a child theme. But when I past the code in the functions.php from my child theme I get a fatal error:
/data/home/secr02/domains/secretsistersblog.com/public_html/wp-content/themes/twentyfourteen-child/functions.php:9) in /data/home/secr02/domains/secretsistersblog.com/public_html/wp-content/themes/twentyfourteen/functions.php on line 197"
I searched on the internet and I think I have to perform a remove action first.
But I have little knowledge of php.
Can somebody maybe help me?
This is what is in the original functions.php:
function twentyfourteen_widgets_init() {
require get_template_directory() . '/inc/widgets.php';
register_widget( 'Twenty_Fourteen_Ephemera_Widget' );
register_sidebar( array(
'name' => __( 'Primary Sidebar', 'twentyfourteen' ),
'id' => 'sidebar-1',
'description' => __( 'Main sidebar that appears on the left.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Content Sidebar', 'twentyfourteen' ),
'id' => 'sidebar-2',
'description' => __( 'Additional sidebar that appears on the right.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Footer Widget Area', 'twentyfourteen' ),
'id' => 'sidebar-3',
'description' => __( 'Appears in the footer section of the site.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
}
add_action( 'widgets_init', 'twentyfourteen_widgets_init' );
Thanks.
Johanna
You can do something like this:-
Add below code in your child theme's functions.php file and add/change code in my_widgets_init function according your desire.
//First Remove Old Action Hook.
remove_action('widgets_init', 'twentyfourteen_widgets_init');
//Register your own hook.
add_action('widgets_init', 'my_widgets_init');
function my_widgets_init()
{
/**
* Add Or Modify Your Code In This Function.
*/
/***Updated Code***/
//require get_template_directory() . '/inc/widgets.php';
//register_widget( 'Twenty_Fourteen_Ephemera_Widget' );
register_sidebar( array(
'name' => __( 'Primary Sidebar', 'twentyfourteen' ),
'id' => 'sidebar-1',
'description' => __( 'Main sidebar that appears on the left.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Content Sidebar', 'twentyfourteen' ),
'id' => 'sidebar-2',
'description' => __( 'Additional sidebar that appears on the right.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Footer Widget Area', 'twentyfourteen' ),
'id' => 'sidebar-3',
'description' => __( 'Appears in the footer section of the site.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
}
How to create a widget area in wordpress pages section. if I add below code in my functions.php file the widget created in dashboard menu section I want to add additional widget in my pages section not in dashboard.
Add a widget to the dashboard.
//This function is hooked into the 'wp_dashboard_setup' action below.
function example_add_dashboard_widgets() {
wp_add_dashboard_widget(
'example_dashboard_widget', // Widget slug.
'Example Dashboard Widget', // Title.
'example_dashboard_widget_function' // Display function.
);
}
add_action( 'wp_dashboard_setup', 'example_add_dashboard_widgets' );
Create the function to output the contents of our Dashboard Widget.
function example_dashboard_widget_function() {
// Display whatever it is you want to show.
echo "Hello World, I'm a great Dashboard Widget";
}
you should register sidebar in functions.php as
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'widget_name',
'id' => 'widget-id',
'description' => 'Type something here',
'before_widget' => '<div id="one" class="two">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
}
it will register sidebar(widget) in your dashboard. Now you can you is it anywhere by
<?php dynamic_sidebar('widget-id'); ?>
This function already exists in default theme
function twentyfourteen_widgets_init() {
require get_template_directory() . '/inc/widgets.php';
register_widget( 'Twenty_Fourteen_Ephemera_Widget' );
register_sidebar( array(
'name' => __( 'Primary Sidebar', 'twentyfourteen' ),
'id' => 'sidebar-1',
'description' => __( 'Main sidebar that appears on the left.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Content Sidebar', 'twentyfourteen' ),
'id' => 'sidebar-2',
'description' => __( 'Additional sidebar that appears on the right.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Footer Widget Area', 'twentyfourteen' ),
'id' => 'sidebar-3',
'description' => __( 'Appears in the footer section of the site.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
}
add_action( 'widgets_init', 'twentyfourteen_widgets_init' );
you can create multiple widget area by copy and pasting this and chage the id every time
register_sidebar( array(
'name' => __( 'new area', 'twentyfourteen' ),
'id' => 'sidebar-5',
'description' => __( 'Appears in the footer section of the site.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
}
In function.php add:
function create_widget($name, $id, $description) {
register_sidebar(array(
'name' => __( $name ),
'id' => $id,
'description' => __( $description ),
'before_widget' => '<div id="'.$id.'" class="widget %1$s %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
}
create_widget("Header", "uptop", "Displays in the header of the site, above the title"); // Create the actual widgets
Then add next code in place u wanna use this area, for example in your header.php:
<?php if ( !dynamic_sidebar('uptop') ); ?>