Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Created November 22, 2016 00:32
Show Gist options
  • Select an option

  • Save hellofromtonya/af8a596486759167ddf0e2d210cffdcc to your computer and use it in GitHub Desktop.

Select an option

Save hellofromtonya/af8a596486759167ddf0e2d210cffdcc to your computer and use it in GitHub Desktop.
How to change the Header Right sidebar registration parameters
add_action( 'register_sidebar', 'change_header_right_registration', 9999 );
/**
* Change the Header Right Sidebar registration parameters.
*
* To change the header right (or any) sidebar registration parameter, you'll
* need to use the global after the sidebar is registered. Within the function
* `register_sidebar()` in WordPress Core, there is an action event after
* the sidebar is registered. We register to that event and then change
* each parameter in the global `$$wp_registered_sidebars`.
*
* @since 1.0.0
*
* @param array $args Sidebar registration arguments
*
* @return void
*/
function change_header_right_registration( array $args ) {
if ( $args['id'] !== 'header-right' ) {
return;
}
global $wp_registered_sidebars;
$wp_registered_sidebars[ $args['id'] ]['name'] = 'Page Name';
$wp_registered_sidebars[ $args['id'] ]['before_title'] = str_replace( '<h3', '<h1', $wp_registered_sidebars[ $args['id'] ]['before_title'] );
$wp_registered_sidebars[ $args['id'] ]['after_title'] = str_replace( '</h3>', '</h1>', $wp_registered_sidebars[ $args['id'] ]['after_title'] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment