Adding a widget area on home

In this simple example, I ‘ll show you how to widgetized the home page of the Customizr theme by placing a widget area above the featured pages.

 

In the following snippet, the widget area is added before the featured pages of the home page with the action hook named ‘__before_fp’.

You can of course use the hooks api of the theme to select another custom location.

 

Paste the following code into your functions.php file. (see how to customize the Customizr theme).

add_filter( 'tc_default_widgets' , 'add_featured_page_widget' );
function add_featured_page_widget( $defaults ) {
	$defaults['fp_widgets'] = array(
                    'name'                 => __( 'Featured Pages Widget' , 'customizr' ),
                    'description'          => __( 'Above the featured pages area on home' , 'customizr' )
	);
    return $defaults;
}

add_action('__before_fp' , 'display_my_fp_widget');
function display_my_fp_widget() {
    dynamic_sidebar('fp_widgets');
}

 

51 thoughts on “Adding a widget area on home”

Comments are closed.