今天学做主题,需要给网站后台添加小工具,是用户可以自己添加想要的东西,wordpress 本以为会很难,然后看了一下wordpress3.0默认主题的sidebar.php的代码,发现了源头, 然后顺藤摸瓜,哈哈,秘密被我发现了!闲话不多说,下面上代码: 1、function注册sidebar小工具(thems=>your theme=>functions.php) `function twentyten_widgets_init() { register_sidebar( array( ‘name’ => __( ‘Primary Widget Area’, ‘twentyten’ ), ‘id’ => ‘primary-widget-area’, ‘description’ => __( ‘The primary widget area’, ‘twentyten’ ), ‘before_widget’ => ‘* ‘, ‘after_widget’ => ‘
‘, ‘before_title’ => ‘

‘, ‘after_title’ => ‘

‘, ) ); }` 解释:name:小工具的名称 id:小工具id,调用时对应id description:小工具描述 before_widget:小工具内容前面的html标签 after_widget:小工具内容后面的html标签 before_title:小工具标题前面的html标签 after_title:小工具标题后面的html标签 2、将调用工具内容的代码放到你要放置的地方 OK ,就这么简单,最后使用css将sidebar小工具的前台样式修饰一下就行了,so easy !