2013-06-26 29 views
0

我在这里新以及在网站开发:) 我有一个关于WordPress的问题。 我尝试制作侧栏小部件。我的主题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(); 
?> 

但它没有出现在列表中的小部件,但是当我点击外观部件,在右侧部分出现在Sidebar 1中,我甚至无法移动它。

你能帮我怎么做吗? 感谢

+0

详细博客:http://sforsuresh.in/wordpress-creating-custom-widget-area/ –

回答

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> 
+0

呀,谢谢。 但我仍然无法拖放它。我也不能用wordpress自己的小工具来做。也许我必须以某种方式在我的模板中激活它? – newbie

+0

您可以通过拖放到侧边栏区域来添加WordPress小部件,如果通过单击标题栏的右下角折叠,则展开该小部件。 –

相关问题