Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding Middle Header Widget – Beautiful Pro Theme
Tagged: Add Widget, beautiful pro, header widget, middle header widget
- This topic has 8 replies, 3 voices, and was last updated 4 years, 9 months ago by Captain Dynamo.
-
AuthorPosts
-
February 28, 2020 at 5:19 am #497015Captain DynamoParticipant
I'm trying to add a Middle Header Widget. I've tried various options but they don't seem to work.
OPTION 1:
1) Registered the widget.
genesis_register_sidebar( array(
'id' => 'middle-header',
'name' => __( 'Middle Header', 'beautiful' ),
'description' => __( 'This is the middle header widget', 'beautiful' ),
) );2) Added widget to the header.
genesis_widget_area( 'after-entry', array(
'before' => '<div class="middle-header widget-area">',
'after' => '</div>',
) );OPTION 2:
1) Register the widget.
genesis_register_sidebar( array(
'id' => 'middle-header',
'name' => __( 'Middle Header', 'beautiful' ),
'description' => __( 'This is the middle header widget', 'beautiful' ),
) );2) Replace header with new header (The below code works for evakona.jp homepage, but does not work for evakona.jp/blog homepage):
-------------------------------------------------------------
//* Add in the new header with the middle widget header
function themeprefix_genesis_do_header() {
global $wp_registered_sidebars;genesis_markup( array(
'html5' => '<div %s>',
'xhtml' => '<div id="title-area">',
'context' => 'title-area',
) );do_action( 'genesis_site_title' );
do_action( 'genesis_site_description' );
echo '</div>';genesis_widget_area( 'header-middle', array(
'before' => '<div class="widget-area header-widget-area">',
'after' => '</div>',
) );if ( ( isset( $wp_registered_sidebars['header-right'] ) && is_active_sidebar( 'header-right' ) ) || has_action( 'genesis_header_right' ) ) {
genesis_markup( array(
'html5' => '<div %s>',
'xhtml' => '<div class="widget-area header-widget-area">',
'context' => 'header-widget-area',
) );
do_action( 'genesis_header_right' );
add_filter( 'wp_nav_menu_args', 'genesis_header_menu_args' );
add_filter( 'wp_nav_menu', 'genesis_header_menu_wrap' );
dynamic_sidebar( 'header-right' );
remove_filter( 'wp_nav_menu_args', 'genesis_header_menu_args' );
remove_filter( 'wp_nav_menu', 'genesis_header_menu_wrap' );genesis_markup( array(
'html5' => '</div>',
'xhtml' => '</div>',
) );
}
}
//* Remove the old header
remove_action( 'genesis_header','genesis_do_header' );
//* Add in the new header above
add_action( 'genesis_header', 'themeprefix_genesis_do_header' );-------------------------------------------------------------------------
http://www.evakona.jp/blogFebruary 28, 2020 at 6:27 am #497016AnitaCKeymasterFebruary 28, 2020 at 6:29 am #497017Captain DynamoParticipantHi Anita,
I tried the coding and it did not work. If there is any alternative, please let me know.
Regards.
February 28, 2020 at 6:37 am #497019AnitaCKeymasterFebruary 28, 2020 at 6:39 am #497020Captain DynamoParticipantYup,
That's the first thing I typed in. If somebody could take a look at the coding I posted, would be nice.
Thanks.
February 28, 2020 at 9:03 am #497023Brad DaltonParticipantI assume you want to add something between the title/logo and nav menu?
Another method would be to add your widget to the header right widget area and position the content in the middle using CSS.
February 28, 2020 at 5:03 pm #497033Captain DynamoParticipantNo.
I'm trying to add a Middle Header Widget between the title/logo and social media icons (which are floated to the right).
Regards.
February 28, 2020 at 5:08 pm #497034Captain DynamoParticipantJust to retiterate, the following code I am using for http://www.evakona.jp to create a Middle Header Widget, but does not seem to work for http://www.evakona.jp/blog:
--------------------------
//* ADD MIDDLE WIDGET AREA
add_action( 'widgets_init', 'genesischild_extra_widgets' );
//Register in new Widget areas
function genesischild_extra_widgets() {
genesis_register_sidebar( array(
'id' => 'header-middle',
'name' => __( 'Header Middle', 'genesischild' ),
'description' => __( 'This is the Header Middle area', 'genesischild' ),
) );
}//* Add in the new header with the middle widget header
function themeprefix_genesis_do_header() {
global $wp_registered_sidebars;genesis_markup( array(
'html5' => '<div %s>',
'xhtml' => '<div id="title-area">',
'context' => 'title-area',
) );do_action( 'genesis_site_title' );
do_action( 'genesis_site_description' );
echo '</div>';genesis_widget_area( 'header-middle', array(
'before' => '<aside class="header-middle widget-area header-widget-area">',
'after' => '</aside>',
) );if ( ( isset( $wp_registered_sidebars['header-right'] ) && is_active_sidebar( 'header-right' ) ) || has_action( 'genesis_header_right' ) ) {
genesis_markup( array(
'html5' => '<aside %s>',
'xhtml' => '<div class="widget-area header-widget-area">',
'context' => 'header-widget-area',
) );
do_action( 'genesis_header_right' );
add_filter( 'wp_nav_menu_args', 'genesis_header_menu_args' );
add_filter( 'wp_nav_menu', 'genesis_header_menu_wrap' );
dynamic_sidebar( 'header-right' );
remove_filter( 'wp_nav_menu_args', 'genesis_header_menu_args' );
remove_filter( 'wp_nav_menu', 'genesis_header_menu_wrap' );genesis_markup( array(
'html5' => '</aside>',
'xhtml' => '</div>',
) );
}
}
//* Remove the old header
remove_action( 'genesis_header','genesis_do_header' );
//* Add in the new header above
add_action( 'genesis_header', 'themeprefix_genesis_do_header' );-----------------------------------
February 28, 2020 at 6:28 pm #497035Captain DynamoParticipantSorry to bother you all.
I've found the solution! It is simply a matter of adding text to the widget to enable it.
All solved.
Regards.
-
AuthorPosts
- The topic ‘Adding Middle Header Widget – Beautiful Pro Theme’ is closed to new replies.