我使用的是一个由“212”主题创建的子主题,该主题包含许多侧边栏,其中一个称为“主侧边栏”。
是否可以将其名称更改为其他名称?
我使用的是一个由“212”主题创建的子主题,该主题包含许多侧边栏,其中一个称为“主侧边栏”。
是否可以将其名称更改为其他名称?
钩入register_sidebar
并在侧栏注册后更改名称。
示例:
add_action( \'register_sidebar\', function( $sidebar )
{
global $wp_registered_sidebars;
if ( \'Main Sidebar\' !== $sidebar[ \'name\' ] )
return;
$id = $sidebar[ \'id\' ];
$sidebar[ \'name\' ] = \'Master\';
$wp_registered_sidebars[ $id ] = $sidebar;
});
如果只想更改名称,则无需注销原始文件。您也可以更改其他属性:
description
class
before_widget
, after_widget
before_title
, after_title
看functions.php 十二个主题的文件。
有twentytwelve_widgets_init 用于注册侧栏的函数。您可以从此处更改侧栏的名称。
您好,我有一个生成错误的短代码。有人能帮忙吗?add_shortcode(\'do-action\', \'do_action_shortcode\'); function do_action_shortcode($atts, $content = \'\') { ob_start(); do_action($content); $out = ob_get_contents(); ob_end_clean(); return $