SHOW:
|
|
- or go back to the newest paste.
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 | - | if (function_exists('register_sidebar')) { |
3 | + | |
4 | - | register_sidebar(array( |
4 | + | |
5 | - | 'name' => 'Sidebar Widgets', |
5 | + | if (function_exists('register_sidebar')) { |
6 | - | 'id' => 'sidebar-widgets', |
6 | + | register_sidebar(array( |
7 | - | 'description' => 'Widget Area', |
7 | + | 'name' => 'Sidebar Left', |
8 | - | 'before_widget' => '<div>', |
8 | + | 'id' => 'sidebar-left', |
9 | - | 'after_widget' => '</div>', |
9 | + | 'description' => 'Widget Area Left', |
10 | - | 'before_title' => '<h2>', |
10 | + | 'before_widget' => '<div class="left-content">', |
11 | - | 'after_title' => '</h2>' |
11 | + | 'after_widget' => '</div>', |
12 | - | )); |
12 | + | 'before_title' => '<h2>', |
13 | - | } |
13 | + | 'after_title' => '</h2>' |
14 | )); | |
15 | } | |
16 | - | <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Widgets') ) : ?> |
16 | + | |
17 | - | <?php endif; ?> |
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; ?> |