prepend and display custom header widget area

Question

so in my functions.php i have a hook as per theme documentation in prepending content before the body. i also create a widget area, which i’d like to be the prepend content, as follows:

// create custom header widget area
function wpb_widgets_init() {

    register_sidebar( array(
        'name'          => 'Custom Header Widget Area',
        'id'            => 'custom-header-widget',
        'before_widget' => '<div class="chw-widget">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2 class="chw-title">',
        'after_title'   => '</h2>',
    ) );

}
add_action( 'widgets_init', 'wpb_widgets_init' );

// prepend and display custom header widget area
add_action( 'before', 'uncode_child_hook_before' );
function uncode_child_hook_before(){
echo <?php

if ( is_active_sidebar( 'custom-header-widget' ) ) : ?>
    <div id="header-widget-area" class="chw-widget-area widget-area" role="complementary">
    <?php dynamic_sidebar( 'custom-header-widget' ); ?>
    </div>

<?php endif; ?>;
}

something must be off with my syntax- i’m a total php novice. thanks in advance.

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/prepend-and-display-custom-header-widget-area/">

prepend and display custom header widget area</a>
0
, , , vulgarbulgar 2 months 0 Answers 88 views 0

Leave an answer