top of page

Creating a Dynamic Sidebar on WP

  • Writer: سُلَيْمَان بْن دَاوُوْد
    سُلَيْمَان بْن دَاوُوْد
  • 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>

 
 
 

Recent Posts

See All
Duplicate Category in Wordpress

The following code helps to duplicate the default wordpress category by help of code. // Add Duplicate option for categories in WordPress...

 
 
 
C#.NET and Its Associated Codes

1- Creating an Desktop Application in C#.NET C# ADO.NET & MySQL MAIN C# and MySQL ADO.NET with Crystals Reports Ready Code 2- Handling...

 
 
 

Comments


© 2020 by syednazrulhassan

bottom of page