I am new to wordpress. I use the code below to display secondary widgets. This code shows all recent posts in the sidebar but I want a secondary widget for a specific category.
<?php dynamic_sidebar( 'secondary-widget-area' ); ?>
You have to register/declare your widgetized area before you can use it. This happens in the functions.php
, so that your theme is aware of the widget area.
<?php
/**
* Register our sidebars and widgetized areas.
*
*/
function arphabet_widgets_init() {
register_sidebar( array(
'name' => 'Home right sidebar',
'id' => 'home_right_1',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'arphabet_widgets_init' );
?>
If you're just trying to add a secondary widget to an existing widgetized area, then no coding is needed. Just go to Appearance>Widgets
and drag and drop HTML blocks or other custom widgets to the appropriate area.