Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Below how to create a two content area (horizontal widgets) in the main page of a wordpress theme to display two articles or else:
- <!-- this code has to be plaaced in the function.php: -->
- if (function_exists('register_sidebar')) {
- register_sidebar(array(
- 'name' => 'Sidebar Left',
- 'id' => 'sidebar-left',
- 'description' => 'Widget Area Left',
- 'before_widget' => '<div class="left-content">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2>',
- 'after_title' => '</h2>'
- ));
- }
- if (function_exists('register_sidebar')) {
- register_sidebar(array(
- 'name' => 'Sidebar Right',
- 'id' => 'sidebar-right',
- 'description' => 'Widget Area Right',
- 'before_widget' => '<div class="right-content">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2>',
- 'after_title' => '</h2>'
- ));
- }
- Here is the CSS to add in the CSS file (style.css or so):
- .left-content { float: left; width: 47%; margin-right: 30px; } /* CSS for the homepage widget on the left */
- .right-content { float: right; width: 47%; margin-right: 20px; } /* CSS for the homepage widget on the right */
- <!-- this code has to pklaced in the location where you needs it (index.php etc.): -->
- <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Left') ) : ?>
- <?php endif; ?>
- <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Right') ) : ?>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement