Provided I have a widget area that I register in genesis like this:

genesis_register_sidebar( array(
    'id'        => 'my_header',
    'name'      => __( 'Image Header', 'my_header' ),
    'description'   => __( 'do it', 'my_header' ),
) );

and that I add as this

add_action( 'genesis_after_header', function() {

    genesis_widget_area ('my_header', array(
        'before' => '<div class="my_header"><div class="my_wrap">',
        'after' => '</div></div>',
    ) );

} );

Then, the user adds 3 text widgets inside the widget area, the question is how can I get the content of this widgets so that I can format them?

Something like this

add_action( 'genesis_after_header', function() {

    the_widget('WP_Widget_Custom_HTML', array(
        'content' => '
            <div> $my_header[text_fields][0].textContent </div>
            <div> $my_header[text_fields][1].textContent</div>
            <div> $my_header[text_fields][2].textContent</div>
} );

NOTE: I've also asked this in stackoverflow https://stackoverflow.com/questions/53139436/wp-genesis-how-to-get-the-content-of-a-widget-in-php, are these two the same community or they do target different publics?

  • You shouldn't post a question twice, stackoverflow.com is more a general topic about programming while WordPress StackExchange is specific to WordPress Nov 4, 2018 at 10:09