Created
May 29, 2015 08:38
-
-
Save neilgee/9a96493bcf9f6a0b7a77 to your computer and use it in GitHub Desktop.
Add extra widgets in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function twentytwelve_widgets_extra() { | |
register_sidebar( array( | |
'name' => __( 'HeaderWidget', 'twentytwelve' ), | |
'id' => 'extraheaderwidget', | |
'description' => __( 'Appears in the header', 'twentytwelve' ), | |
'before_widget' => '<div id="%1$s" class="mynewheaderclass">', | |
'after_widget' => '</div;>', | |
'before_title' => '<h2>', | |
'after_title' => '</h2>', | |
) ); | |
} | |
add_action( 'widgets_init', 'twentytwelve_widgets_extra' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function twentytwelvechild_widgets_extra() { | |
register_sidebar( array( | |
'name' => __( 'HeaderWidget', 'twentytwelve' ), | |
'id' => 'extraheaderwidget', | |
'description' => __( 'Appears in the header', 'twentytwelve' ), | |
'before_widget' => '<aside id="%1$s">', | |
'after_widget' => '</aside>', | |
'before_title' => '<h3>', | |
'after_title' => '</h3>', | |
) ); | |
} | |
add_action( 'widgets_init', 'twentytwelvechild_widgets_extra' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<?php if ( is_active_sidebar( 'extraheaderwidget' ) ) : ?> | |
<?php dynamic_sidebar( 'extraheaderwidget' ); ?> | |
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?> | |
<div id="secondary" class="widget-area" role="complementary"> | |
<?php dynamic_sidebar( 'sidebar-1' ); ?> | |
</div><!-- #secondary --> | |
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function twentytwelve_widgets_init() { | |
register_sidebar( array( | |
'name' => __( 'Main Sidebar', 'twentytwelve' ), | |
'id' => 'sidebar-1', | |
'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ), | |
'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', 'twentytwelve_widgets_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment