Mudanças entre as edições de "Wordpress Registrar Sidebar"
De Babel Digital
(Criou página com 'Vamos em functions.php e colocar o código abaixo pra ter no barra lateral o Widgets e assim poder utilizar <?php if ( function_exists('register_sidebar') ) register_sideba…') |
|||
| (8 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
| Linha 1: | Linha 1: | ||
Vamos em functions.php e colocar o código abaixo pra ter no barra lateral o Widgets e assim poder utilizar | Vamos em functions.php e colocar o código abaixo pra ter no barra lateral o Widgets e assim poder utilizar | ||
| + | |||
| + | http://codex.wordpress.org/Function_Reference/register_sidebar<br\> | ||
| + | http://codex.wordpress.org/Function_Reference/register_sidebars | ||
| + | |||
<?php | <?php | ||
if ( function_exists('register_sidebar') ) | if ( function_exists('register_sidebar') ) | ||
| Linha 5: | Linha 9: | ||
?> | ?> | ||
| + | |||
| + | Registro e Argumentos possíveis: | ||
| + | <pre> | ||
| + | <?php register_sidebar( $args ); ?> | ||
| + | |||
| + | <?php $args = array( | ||
| + | 'name' => sprintf(__('Sidebar do Top %d'), $i ), | ||
| + | 'id' => 'sidebar-$i', | ||
| + | 'description' => '', | ||
| + | 'before_widget' => '<li id="%1$s" class="widget %2$s">', | ||
| + | 'after_widget' => '</li>', | ||
| + | 'before_title' => '<h2 class="widgettitle">', | ||
| + | 'after_title' => '</h2>' ); ?> | ||
| + | </pre> | ||
| + | |||
| + | |||
| + | See How Easy It Is To Widgetize WordPress Themes<br\> | ||
| + | http://www.themelab.com/2008/04/18/see-how-easy-it-is-to-widgetize-wordpress-themes/ | ||
| + | |||
| + | Registrando duas sidebar, esquerda e direita | ||
| + | <pre> | ||
| + | if ( function_exists('register_sidebar') ) | ||
| + | register_sidebar(array( | ||
| + | 'name' => 'Sidebar Esquerda', | ||
| + | 'before_widget' => '', | ||
| + | 'after_widget' => '', | ||
| + | 'before_title' => '<h2>', | ||
| + | 'after_title' => '</h2>', | ||
| + | )); | ||
| + | |||
| + | if ( function_exists('register_sidebar') ) | ||
| + | register_sidebar(array( | ||
| + | 'name' => 'Sidebar Direita', | ||
| + | 'before_widget' => '', | ||
| + | 'after_widget' => '', | ||
| + | 'before_title' => '<h2>', | ||
| + | 'after_title' => '</h2>', | ||
| + | )); | ||
| + | </pre> | ||
| + | |||
| + | Como cada um tem nome/name, no tema somente chamar o nome da sidebar onde deseja usar, e nela colocar os Widgets que melhor for pra seu site. | ||
| + | |||
| + | Na esquerda: | ||
| + | <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Sidebar Esquerda") ) : ?> | ||
| + | <?php endif; ?> | ||
| + | |||
| + | E na direita: | ||
| + | <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Sidebar Direita") ) : ?> | ||
| + | <?php endif; ?> | ||
Edição atual tal como às 13h51min de 24 de maio de 2011
Vamos em functions.php e colocar o código abaixo pra ter no barra lateral o Widgets e assim poder utilizar
http://codex.wordpress.org/Function_Reference/register_sidebar<br\> http://codex.wordpress.org/Function_Reference/register_sidebars
<?php
if ( function_exists('register_sidebar') )
register_sidebar();
?>
Registro e Argumentos possíveis:
<?php register_sidebar( $args ); ?>
<?php $args = array(
'name' => sprintf(__('Sidebar do Top %d'), $i ),
'id' => 'sidebar-$i',
'description' => '',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>' ); ?>
See How Easy It Is To Widgetize WordPress Themes<br\>
http://www.themelab.com/2008/04/18/see-how-easy-it-is-to-widgetize-wordpress-themes/
Registrando duas sidebar, esquerda e direita
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Sidebar Esquerda',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Sidebar Direita',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
Como cada um tem nome/name, no tema somente chamar o nome da sidebar onde deseja usar, e nela colocar os Widgets que melhor for pra seu site.
Na esquerda:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Sidebar Esquerda") ) : ?>
<?php endif; ?>
E na direita:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Sidebar Direita") ) : ?>
<?php endif; ?>