Creating a Dynamic Sidebar on WP
- سُلَيْمَان بْن دَاوُوْد

- Sep 13, 2020
- 1 min read
Creating a new sidebar is useful many times
The HTML

The Registered Widget to Mimic HTML Above

The Replaced HTML Code

The Backend Code

function archiveblog_sidebars() {
$args = array(
'id' => 'archiveblog',
'class' => 'archiveblog',
'name' => __( 'Blog Archive', 'text_domain' ),
'description' => __( 'Used to display Blog Archives', 'text_domain' ),
'before_title' => '<h1 class="blogarchive">',
'after_title' => '</h1>',
'before_widget' => '<div class="col-6 col-md-12 sidebar-recent">',
'after_widget' => '</div>',
);
register_sidebar( $args );
}
add_action( 'widgets_init', 'archiveblog_sidebars' );<div class="row">
<?php if ( is_active_sidebar( 'archiveblog' ) ) : ?>
<?php dynamic_sidebar( 'archiveblog' ); ?>
<?php endif; ?>
</div>
Comments