0

の後に関数を割り当てるにはどうすればよい</section>ですか? 配列に?

<?php
function roots_widgets_init() {
    register_sidebar(array(
        'name'          => __('Footer', 'roots'),
        'id'            => 'sidebar-footer',
        'before_widget' => '<section class="widget span4 %1$s %2$s"><div class="widget-inner">',
        'after_widget'  => '</div></section>',
        'before_title'  => '<h3>',
       'after_title'   => '</h3>', 
    ));
}
?>

編集#1(これを思いつきましたが、適切に機能していません</div><div class="row-fluid">。3つのウィゲット/セクションごとに生成しようとしています。):

<?php
$i = 1;
function name () {
    if($i % 3 == 0) {
        return "</div><div class=\"row-fluid\">";
    } else {
    return;  
    }
    $i++;   
}
function roots_widgets_init() {
    register_sidebar(array(
        'name'          => __('Footer', 'roots'),
        'id'            => 'sidebar-footer',
        'before_widget' => '<section class="widget span4 %1$s %2$s"><div class="widget-inner">',
        'after_widget'  => '</div></section>' . name(),
        'before_title'  => '<h3>',
       'after_title'   => '</h3>', 
    ));
}
?>

みんなありがとう!

4

1 に答える 1

0

あなたが求めていることを100%確信しているわけではありませんが、関数の戻り値を好きな場所に配置できます。

function roots_widgets_init() {
    register_sidebar(array(
        'name'          => __('Footer', 'roots'),
        'id'            => 'sidebar-footer',
        'before_widget' => '<section class="widget span4 %1$s %2$s"><div class="widget-inner">',
        'after_widget'  => '</div></section>' . get_after_section(),
        'before_title'  => '<h3>',
        'after_title'   => '</h3>', 
    ));
}

の戻り値get_after_sectionを「after_widget」の現在の値に追加します。

于 2013-07-14T19:30:21.247 に答える