0

我是新来的,也是网络开发的:) 我有一个关于 wordpress 的问题。我尝试制作侧边栏小部件。

在我的 sidebar.php 文件中,我写道:

<div id="sidebar">

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>

<div>some html here </div>

<?php endif; ?>

在function.php中

<?php
if ( function_exists('register_sidebars') )
    register_sidebar();
?>

但是它没有出现在小部件列表中,但是当我单击外观小部件时,它在右侧出现了侧边栏 1,我什至无法移动它。

你能帮我怎么做吗?谢谢

4

1 回答 1

1

在你的functions.php

if ( function_exists('register_sidebar') ){
    register_sidebar(array(
        'name' => 'Sidebar',
        'id' => 'sidebar_widget_1',
        'description' => 'Widgets in this area will be shown in the sidebar.',
        'before_widget' => '<div id="%1$s" class="%2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h2>',
        'after_title' => '</h2>'
    )
);

在你的sidebar.php

<div id="sidebar">
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar') ) : ?>
        <div>some html here </div>
    <?php endif; ?>
</div>
于 2013-06-26T05:39:47.573 回答