Home » How to register sidebar : | wordpress theme development part-9

How to register sidebar : | wordpress theme development part-9

हेलो दोस्तों इस पार्ट में हम सीखेंगे की कैसे हम अपने थीम में साइड बार  add  कर सकते है | sidebar  add  करने का example  niche  दिया है | आप  इसका प्रयोग करके आसानी से अपने थीम में साइडबार add  कर सकते है more info

<strong>//Register sidebar</strong>
<strong>function register_mani_first_sidebar(){</strong>
<strong>        register_sidebar(array(</strong>
<strong>            'name'=>__('Primary Sidebar','theme_name'),</strong>
<strong>            'id'=>'sidebar-1',</strong>
<strong>            'before_widget'=>'<aside id="%1$s" class="%2$s"',</strong>
<strong>            'after_widget'=>'</aside>',</strong>
<strong>            'before_title'=>'<h1 class="widget-title">',</strong>
<strong>            'after_title'=>'</h1>',</strong>
<strong>        ));</strong>
<strong>    }</strong>
<strong>    add_action('widgets_init','register_mani_first_sidebar');</strong>Code language: JavaScript (javascript)

How to display sidebar :

दोस्तों यदि आप अपने siderbar में add items को display कराना चाहते हो तो इसके लिए आपको नीचे  दिए गए कोड को use  करना होगा |  more info

<!-- For Checking Sidebar is active or not  -->
<?php if(is_active_sidebar('sidebar-1')): ?>
        <div class="first_sidebar">
            <!-- Display Sidebar  -->
            <?php dynamic_sidebar('sidebar-1'); ?>
        </div>
<?php endif; ?> Code language: HTML, XML (xml)