请帮我解决这个错误。我是编码新手,我有一个 wordpress 网站,它显示以下错误
Warning: Illegal string offset 'custom_css_post_id' in /home/content/n3pnexwpnas02_data02/18/3031418/html/wp-includes/theme.php on line 905
我应该从哪里开始。有人可以帮助我,因为我是菜鸟。
这是它在 theme.php 中指向的代码
function wp_get_custom_css_post( $stylesheet = '' ) {
if ( empty( $stylesheet ) ) {
$stylesheet = get_stylesheet();
}
$custom_css_query_vars = array(
'post_type' => 'custom_css',
'post_status' => get_post_stati(),
'name' => sanitize_title( $stylesheet ),
'posts_per_page' => 1,
'no_found_rows' => true,
'cache_results' => true,
'update_post_meta_cache' => false,
'update_term_meta_cache' => false,
);
$post = null;
if ( get_stylesheet() === $stylesheet ) {
$post_id = get_theme_mod( 'custom_css_post_id' );
if ( $post_id > 0 && get_post( $post_id ) ) {
$post = get_post( $post_id );
} else {
$query = new WP_Query( $custom_css_query_vars );
$post = $query->post;
/*
* Cache the lookup. See WP_Customize_Custom_CSS_Setting::update().
* @todo This should get cleared if a custom_css post is added/removed.
*/
if ( $post ) {
set_theme_mod( 'custom_css_post_id', $post->ID );
} elseif ( -1 !== $post_id ) {
set_theme_mod( 'custom_css_post_id', -1 );
}
}
} else {
$query = new WP_Query( $custom_css_query_vars );
$post = $query->post;
}
return $post;
最佳答案
我是如何解决这个问题的
- 切换到另一个默认主题(我使用了二十九)并重新分配了一个主菜单。
- 进入数据库并在选项中搜索“theme_mods_”,其中每个主题都应该有一个。一个是你的坏主题,你应该罚款另一个二十九。
- 复制 219 中的选项值并将其设置为您损坏的主题的值。然后将其切换回来并再次分配主菜单。
这可能不是最好的解决方案,但它确实有效。
关于php - 警告 : Illegal string offset 'custom_css_post_id' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41198724/