我试图自定义WordPress主题,但它显示了此错误。
您的主题有2个小部件区域,但此特定页面不显示它们。您可以导航到站点上的其他页面,同时使用自定义程序查看>和编辑这些页面上显示的小部件。
首先,没有显示小部件区域,所以我添加了此代码,然后它显示小部件,但现在显示上述错误。
if (function_exists("register_sidebar")) {
register_sidebar();
}
这是我的职责。php文件如何解决此问题。是否要更改其他页面?
<?php
/**
* Enqueues scripts and styles.
*
*/
if (function_exists("register_sidebar")) {
register_sidebar();
}
function umk_enque_scripts() {
wp_enqueue_style( \'normalize-style\', get_template_directory_uri() . \'/css/normal.css\' );
wp_enqueue_style( \'umkthemes-style\', get_stylesheet_uri() );
wp_enqueue_style( \'custom-css\', get_template_directory_uri() . \'/css/custom.css\' );
wp_enqueue_style( \'landmark\', get_template_directory_uri() . \'/css/landmark-map.css\' );
// wp_enqueue_script( \'umkthemes-script\', get_template_directory_uri(). \'/js/responsiveslides.min.js\', array( \'jquery\' ), \'1.0\' );
}
add_action( \'wp_enqueue_scripts\', \'umk_enque_scripts\' );
function umkthemes_setup() {
add_theme_support (\'menus\');
add_theme_support( \'post-thumbnails\' );
// set_post_thumbnail_size( 273 , 146 );
register_nav_menus( array(
\'primary_menu\' => \'Main navigation\',
) );
}
add_action( \'after_setup_theme\', \'umkthemes_setup\' );
// Our custom post type function
function create_posttype() {
register_post_type( \'sale\',
// CPT Options
array(
\'labels\' => array(
\'name\' => __( \'Sale\' ),
\'singular_name\' => __( \'Sale\' ),
\'all_items\' => __(\'All Sales\', \'umkthemes\'), /* the all items menu item */
\'add_new\' => __(\'Add New Sale\', \'umkthemes\'), /* The add new menu item */
\'add_new_item\' => __(\'Add New Sale\', \'umkthemes\'), /* Add New Display Title */
\'edit\' => __( \'Edit\', \'jointstheme\' ), /* Edit Dialog */
\'edit_item\' => __(\'Edit Sale\', \'umkthemes\'), /* Edit Display Title */
\'new_item\' => __(\'New Sale\', \'umkthemes\'), /* New Display Title */
\'view_item\' => __(\'View Sale\', \'umkthemes\'), /* View Display Title */
\'search_items\' => __(\'Search Sale\', \'umkthemes\'), /* Search Custom Type Title */
),
\'public\' => true,
\'has_archive\' => true,
\'rewrite\' => array(\'slug\' => \'sale\'),
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', )
)
);
}
// Hooking up our function to theme setup
add_action( \'init\', \'create_posttype\' );
SO网友:maverick
错误:您的主题有2个小部件区域,但此特定页面不显示它们。您可以导航到站点上的其他页面,同时使用自定义程序查看>和编辑这些页面上显示的小部件。
这是因为主题可能在特定页面上使用有条件加载小部件,即。,
if ( is_single() ) :
get_sidebar( \'primary\' );
endif;
如果您所在的页面不支持小部件,WordPress将显示该消息
在函数中删除此代码。php文件
if (function_exists("register_sidebar")) {
register_sidebar();
}
并包括包含该函数的文件(register\\u sidebar())
例如:require_once WP_CONTENT_DIR . \'/includes/function-file.php\';
或者您可以直接在函数中注册侧栏。php文件,如:
add_action( \'widgets_init\', \'my_register_sidebars\' );
function my_register_sidebars() {
/* Register the \'primary\' sidebar. */
register_sidebar(
array(
\'id\' => \'primary\',
\'name\' => __( \'Primary Sidebar\' ),
\'description\' => __( \'A short description of the sidebar.\' ),
\'before_widget\' => \'<div id="%1$s" class="widget %2$s">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h3 class="widget-title">\',
\'after_title\' => \'</h3>\',
)
);
/* Repeat register_sidebar() code for additional sidebars. */
}
要在主题模板中显示侧栏(通常需要创建一个sidebar.php文件),请粘贴以下代码
<div id="sidebar-primary" class="sidebar">
<?php if ( is_active_sidebar( \'primary\' ) ) : ?>
<?php dynamic_sidebar( \'primary\' ); ?>
<?php else : ?>
<!-- Time to add some widgets! -->
<?php endif; ?>
</div>