什麼是添加「文本組件」,並在文本輸入數據中的文本輸入將增加類控件像WordPress的 - 添加類Widget的文本
<aside id="text-2" class="widget widget_text custom_class_here">
...
</aside>
我的方式方法是取消註冊窗口小部件文字並重新創建。但我認爲會有更好的辦法。如何做到這一點謝謝
什麼是添加「文本組件」,並在文本輸入數據中的文本輸入將增加類控件像WordPress的 - 添加類Widget的文本
<aside id="text-2" class="widget widget_text custom_class_here">
...
</aside>
我的方式方法是取消註冊窗口小部件文字並重新創建。但我認爲會有更好的辦法。如何做到這一點謝謝
在functions.php文件中註冊了側邊欄。例如
register_sidebar(array(
'name' => __('Main Sidebar', 'twentytwelve'),
'id' => 'sidebar-1',
'description' => __('Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve'),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
));
你想要做的是添加自定義類在aside
例如
register_sidebar(array(
'name' => __('Main Sidebar', 'twentytwelve'),
'id' => 'sidebar-1',
'description' => __('Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve'),
'before_widget' => '<aside id="%1$s" class="widget %2$s my_custom_class_here">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
));
對不起。但是我想將輸入文本添加到'defaut widget text'?那可能嗎? – DeLe 2014-09-14 03:17:30
可以過濾整個文本並做字符串替換或補充具有:
add_filter('widget_text', 'widget_so_25825107', 10, 2);
function widget_so_25825107($text, $instance) {
$new_text = "manipulate $text here";
return $new_text
}
你可以只安裝這個插件:https://wordpress.org/plugins/widget-options/你可以選擇在每個小部件上添加自定義類和ID。謝謝! – 2016-04-28 14:36:57