/**
 * Register a new theme location in Elementor.
 *
 * @param Locations_Manager $location_manager Elementor theme location manager.
 */
function dorzki_register_new_elementor_location( $location_manager ) {

  $args = [
    'label' => esc_html__( 'Top Bar', 'dorzki' ),
    'multiple' => false,
    'edit_in_content' => true,
    'public' => true,
    'hook' => 'dorzki_elementor_location_top_bar'
  ];

	$location_manager->register_location( 'top_bar', $args );

}

add_action( 'elementor/theme/register_locations', 'dorzki_register_new_elementor_location' );
/**
 * Add this line in the location you want the location to be displayed.
 */
elementor_theme_do_location( 'top_bar' );

How to use it?

Usually adding functionality to a WordPress site is by creating a plugin.
However you can simply copy the code and paste it in your child theme’s functions.php file at the end of the file, just before ?>.

For JavaScript code you will need to add them to your theme’s main JavaScript file.

Having issues with the code?

If the code doesn’t work or you get an error please let us know in the comments section.
We will do our best to fix it as-soon-as-possible and update the code on this page.

Comments

Leave a Reply