All Articles Kinsa Creative

Using WordPress Widgets to Place Specific Content on a Page

The Function

Add to the WordPress theme's functions.php file:

// Add ability to create widgets
function create_widget( $name, $id, $description ) {
    register_sidebar( array(
        'name' => __( $name ),
        'id' => $id,
        'description' => __( $description ),
        'before_widget' => '
', // this div will wrap the widget 'after_widget' => '
', 'before_title' => '

', // widgets have an optional Title, this markup sets up wrapping that title in an H2 tag 'after_title' => '

' ) ); } // Create a widget for an Education Schedule using our new function, passing the variables for name, ID, and description create_widget( 'Education Schedule', 'education-schedule', 'Education Schedule.' );

In the template, check to see if the widget is set using the name as a reference. If so, output it:

<?php if ( is_active_sidebar( 'education-schedule' ) ): ?>
    <?php dynamic_sidebar( 'education-schedule' ); ?>
<?php endif; ?>

In the WP Admin, under AppearanceWidgets, drag a Text, HTML, or other widget onto the Education Schedule block.


Email us at