我一直在为我的 wopress 网站离线处理这个代码错误。
解析错误:语法错误,C:\Users\guyzer\Desktop\InstantWP_4.3\iwpserver\htdocs\wordpress\wp-content\themes\thesis_182\custom\custom_functions.php 中的意外 '[' 在第 169 行
行代码错误第 169 行: $post_date = explode(" ", $post_event)[0];
在实时站点上,站点正在运行,但是当我使用复制器复制实时站点并传输到离线或其他服务器时,总是会发生此错误,从而导致站点关闭。我希望你能帮我解决这个错误!
这是错误的完整代码:
<div class="page">
<div class="tab-sidebars">
<h1><a href="<?php echo get_site_url()?>/gigs">GIGS</a></h1>
<h3><a href="<?php echo get_site_url()?>/gigs/today">• Today</a></h3>
<h3><a href="<?php echo get_site_url()?>/gigs/weeks">• Weeks</a></h3>
<h3><a href="<?php echo get_site_url()?>/gigs/month">• Month</a></h3>
</div>
<div id="gigs-carousel" class="post-container">
<a class="buttons prev" href="#"></a>
<div class="viewport">
<ul class="overview" style="width:9999px !important">
<?php
global $post;
$today = getdate();
$args = array( 'category_name' => 'gigs',
'post_type' => 'post',
'meta_key' => custom_event_date,
'orderby' => meta_value,
'order' => 'ASC',
'showposts' => '99'
);
$the_query = new WP_Query($args);
while($the_query->have_posts()) :
$the_query->the_post();
$post_id = $post->ID;
$post_event = get_post_meta($post_id, 'custom_event_date', true);
$post_date = explode(" ", $post_event)[0];
$post_time = explode(" ", $post_event)[1];
$post_day = explode("-", $post_date)[2];
$post_permalink = get_permalink($post_id);
$thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'thumbnail' );
$date_now = date("Y-m-d H:i");
$date_compare = $post_event;
$date_result = strtotime($date_compare) - strtotime($date_now);
$current_month = date("m");
$event_month = explode("-", $post_date)[1];
if($date_result > 0 && $current_month == $event_month) :
?>
<li style="background-image:url(<?php echo $thumbnail_src[0]?>)">
<div class='post-day'><?php echo $post_day?></div>
<a class='post-item' href="<?php echo $post_permalink?>" >
<div class='post-title'><?php echo get_the_title();?></div>
<div class='post-sub'><?php echo convert_time($post_time)?></div>
<div class='post-excerpt'><?php the_excerpt(); ?></div>
</a>
</li>
<?php
endif;
endwhile;
wp_reset_postdata();
?>
</ul>
</div><!-- .viewport -->
<a class="buttons next" href="#"></a>
</div><!-- #gigs-carousel -->
</div>