Advertisement
cypherinfo

Code for displaying two content area (horizontal widgets)

Oct 19th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Below how to create a two content area (horizontal widgets) in the main page of a wordpress theme to display two articles or else:
  2.  
  3. <!-- this code has to be plaaced in the function.php: -->
  4.  
  5. if (function_exists('register_sidebar')) {  
  6.       register_sidebar(array(  
  7.        'name' => 'Sidebar Left',  
  8.        'id'   => 'sidebar-left',  
  9.        'description'   => 'Widget Area Left',  
  10.        'before_widget' => '<div class="left-content">',  
  11.        'after_widget'  => '</div>',  
  12.        'before_title'  => '<h2>',  
  13.        'after_title'   => '</h2>'  
  14.       ));  
  15.      }  
  16.      
  17. if (function_exists('register_sidebar')) {  
  18.       register_sidebar(array(  
  19.        'name' => 'Sidebar Right',  
  20.        'id'   => 'sidebar-right',  
  21.        'description'   => 'Widget Area Right',  
  22.        'before_widget' => '<div class="right-content">',  
  23.        'after_widget'  => '</div>',  
  24.        'before_title'  => '<h2>',  
  25.        'after_title'   => '</h2>'  
  26.       ));  
  27.      }
  28.  
  29. Here is the CSS to add in the CSS file (style.css or so):
  30.  
  31. .left-content { float: left; width: 47%; margin-right: 30px; } /* CSS for the homepage widget on the left */
  32. .right-content { float: right; width: 47%; margin-right: 20px; }  /* CSS for the homepage widget on the right */
  33.  
  34. <!-- this code has to pklaced in the location where you needs it (index.php etc.): -->
  35. <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Left') ) : ?>  
  36.                <?php endif; ?>         
  37. <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Right') ) : ?>  
  38.                <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement