wordpress - How to use Widgets in css -
i trying create widget in wordpress when go dashboard , click under appearance, don't see option widgets. can see themes,customize, menus, theme check , editor. do widgets can start creating own ones?
you need register sidebar widget first in functions.php
file:
<?php add_action( 'widgets_init', 'my_register_sidebars' ); function my_register_sidebars() { /* register 'primary' sidebar. */ register_sidebar( array( 'id' => 'primary', 'name' => __( 'primary' ), 'description' => __( 'a short description of sidebar.' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) ); /* repeat register_sidebar() code additional sidebars. */ } ?>
then call widget wherever want show up, either sidebar or anywhere in theme.
<?php if ( is_active_sidebar( 'primary' ) ) : ?> <div id="sidebar-primary" class="sidebar"> <?php dynamic_sidebar( 'primary' ); ?> </div> <?php endif; ?>
Comments
Post a Comment