Advertisement
getakter

Widget Register & Use

Nov 13th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. /*******Register WIDGET************/
  2.  
  3. function create_widget( $name, $id, $description ) {
  4.  
  5.     register_sidebar(array(
  6.         'name' => __( $name ),   
  7.         'id' => $id,
  8.         'description' => __( $description ),
  9.         'before_widget' => '<div class="widget">',
  10.         'after_widget' => '</div>',
  11.         'before_title' => '<h4>',
  12.         'after_title' => '</h4>'
  13.     ));
  14.  
  15. }
  16.  
  17. create_widget( 'Front Page Left', 'front-left', 'Displays on the left of the homepage' );
  18. create_widget( 'Front Page Center', 'front-center', 'Displays in the center of the homepage' );
  19. create_widget( 'Front Page Right', 'front-right', 'Displays on the right of the homepage' );
  20. create_widget( 'Page Right', 'page-right', 'Displays on the right of the page' );
  21. create_widget( 'Blog Right', 'blog', 'Displays on the right of the blog page' );
  22.  
  23.  
  24. //Call the Sidebar
  25.  
  26. <div class="col-md-3 page_widget">
  27.       <?php if (!dynamic_sidebar('blog')):?>
  28.           <h2>Widget Alert</h2>
  29.           <p>Please add your widget from widger section</p>
  30.        <?php endif;?>
  31. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement