PHP Wordpress错误-站点不工作
在将新主题上传到我的wordpress网站时,似乎出现了此错误 错误如下 致命错误:无法在中的写入上下文中使用函数返回值 /home/shutz1/public_html/justserviceofny.com/wp-content/themes/justserviceofny -第16行新站点/front-page.php 如果这有帮助,下面是完整的代码PHP Wordpress错误-站点不工作,php,wordpress,Php,Wordpress,在将新主题上传到我的wordpress网站时,似乎出现了此错误 错误如下 致命错误:无法在中的写入上下文中使用函数返回值 /home/shutz1/public_html/justserviceofny.com/wp-content/themes/justserviceofny -第16行新站点/front-page.php 如果这有帮助,下面是完整的代码 <?php /** * Home Page template * * @package WordPress * @subp
<?php
/**
* Home Page template
*
* @package WordPress
* @subpackage JustServiceOfNewYork
* @since JustServiceOfNewYork 1.0
*/
get_header();
?>
<div class="home-banner" style="background: url('<?= ot_get_option('home-banner'); ?>');
<?= !empty(ot_get_option('home-banner-height')) ? 'height:' . ot_get_option('home-banner-height') . 'px;' : ''; ?>"
></div>
<div class="content-wrapper">
<div class="main-content">
<?php
// Start the loop.
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', 'home' );
endwhile; // End the loop.
?>
</div><!--.main-content-->
<?php if ( vct_get_sidebar_class() ) : ?>
<?php get_sidebar(); ?>
<?php endif; ?>
</div><!--.content-wrapper-->
<?php get_footer();
这很可能是因为您在函数返回中使用了以下命令:
!empty(ot_get_option('home-banner-height')) ? 'height:' ....
把这行改成
ot_get_option('home-banner-height') ? 'height:'...
只需卸下盖子!空的替换代码:
<div class="home-banner" style="background: url('<?= ot_get_option('home-banner'); ?>');
<?= !empty(ot_get_option('home-banner-height')) ? 'height:' . ot_get_option('home-banner-height') . 'px;' : ''; ?>">
</div>
与
因为,你在呼应高度。但作为您的代码,它没有任何响应。更新代码
<?php $hb = ot_get_option('home-banner'); ?>
<div class="home-banner" style="background: url('<?= echo $hb; ?>');"
<?= $hbh = ot_get_option('home-banner-height');
echo !empty($hbh) ? 'height:' . $hbh . 'px;' : ''; ?>></div>
你的if-else速记有问题。你必须回应它。解释一下你改变了什么,以及为什么它有助于解决问题,这将改善这个答案。
<?php $hb = ot_get_option('home-banner'); ?>
<div class="home-banner" style="background: url('<?= echo $hb; ?>');"
<?= $hbh = ot_get_option('home-banner-height');
echo !empty($hbh) ? 'height:' . $hbh . 'px;' : ''; ?>></div>