今天要跟大家分享 如何啟動Wordpress的小工具,並且顯示在側邊欄呢
步驟一:編輯function.php 加入register_sidebar
1.加入程式碼:
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'Sidebar Widgets',
'id' => 'sidebar-widgets',
'description' => 'Widget Area',
'before_widget' => '<div id="one" class="two">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
}
2.這是後台的 「外觀」子選單會多出 「小工具」
3.可以想把想要的小工具先加進去
步驟二:把小工具程式碼顯示在你想顯示的地方
<div class="sidebar">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Widgets') ) : ?>
<?php endif; ?>
</div>
這時再來看看前台吧!