Pregunta

Renuncia: estoy completamente nuevo a WP.

Estoy utilizando el Starkers HTML5 eje temático . En el functions.php veo este código:

function starkers_widgets_init() {

  // Area 1, located at the top of the sidebar.
  register_sidebar( array(
    'name' => __( 'Primary Widget Area', 'starkers' ),
    'id' => 'primary-widget-area',
    'description' => __( 'The primary widget area', 'starkers' ),
    'before_widget' => '<li>',
    'after_widget' => '</li>',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
  ) );

  // Area 3, located in the footer. Empty by default.
  register_sidebar( array(
    'name' => __( 'First Footer Widget Area', 'starkers' ),
    'id' => 'first-footer-widget-area',
    'description' => __( 'The first footer widget area', 'starkers' ),
    'before_widget' => '<li>',
    'after_widget' => '</li>',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
  ) );

  // ... more calls to register_sidebar() ... 
}

Y en footer.php veo este código:

<?php get_sidebar( 'footer' ); ?>

No entiendo cómo get_sidebar() sabe cómo tomar ese argumento de cadena y encontrar los reproductores adecuados que fueron definidos por register_sidebar(). En el functions.php fragmento que he publicado anteriormente. No hay ninguna mención de "pie" a excepción de las propiedades name, id y description. Pero parecería extraño para mí que get_sidebar() sería buscar 'pie de página' dentro de esas propiedades.

¿Esto tiene sentido lo que estoy pidiendo? ¿Hay alguna pieza que falta?

Las razones por las que estoy pidiendo es porque - Me gustaría saber más acerca de la arquitectura WP -. Me gustaría ser capaz de definir un área de widget personalizado y saber cómo representar en una página específica

Gracias una tonelada.

¿Fue útil?

Solución

You just call get_sidebar() from index.php and it loads the theme file sidebar.php.

register_sidebar(), on the other hand, is used for widgets where plugins and such want to dynamically add content in your sidebar.php file if your theme supports it.

In your case, is there a file called sidebar-footer.php in your theme's directory?

Otros consejos

I've never bothered with get_sidebar(). Instead I just use dynamic_sidebar(). You'd call it like this:

dynamic_sidebar('first-footer-widget-area');

And that takes care of the whole sidebar. No more file inclusions, no more cluttered theme folders. If I want to have 5 different sidebars, it doesn't add any files, only extra functions in functions.php.

get_sidebar('name') gets a sidebar template of the name sidebar-name.php .

Within sidebar-name.php, there is the HTML for the sidebar, and a call to dynamic_sidebar('some-name-hopefully-the-same'), which is where the widgets will go.

register_sidebar(array(name=>'some-name-hopefully-the-same', ...)) is what allows dynamic_sidebar to work.

As you can see, get_sidebar(templatename) is for use with sidebar-templates. If you have no need for them, you can just call dynamic_sidebar(sidebarname) directly from your theme.

get_sidebar('footer') attempts to load sidebar-footer.php from the active theme. Starkers does provide this file. Check starkers/sidebar-footer.php and things should become clear.

Licenciado bajo: CC-BY-SA con atribución
scroll top