![](/img/trans.png)
[英]Parse error: syntax error, unexpected ';', expecting ')' (Wordpress functions.php)
[英]Wordpress plugin PHP Parse error: syntax error, unexpected '{', expecting ')'
我正在其他人建立的Wordpress網站上做一些工作。 他們制作了一個自定義插件,但不再與公司合作。 該插件會在實時站點上加載,但不會在測試服務器上加載,因此很難進行更改。
在測試服務器上加載插件會出現錯誤:
Parse error: syntax error, unexpected '{', expecting ')' in wp-content/plugins/uni-todays-program/todays-program.php on line 221
221行是:
$query = new WP_Query( [
周圍的代碼是:
// [today]
function today_func( $atts ) {
// Retrieve current days schedule
$today = getdate();
$query = new WP_Query( [
'post_type' => 'day_entry',
'year' => $today["year"],
'monthnum' => $today["mon"],
'day' => $today["mday"] ,
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
] );
$day_type = $query->post->day_type;
$query = new WP_Query( ['post_type' => 'day_type','name' => $day_type] );
return $query->post->post_content;
}
add_shortcode( 'today', 'today_func' );
我只是一個前端人員,所以我的PHP非常有限,但看不到問題。 沒有開口(
需要關閉。
我用Google做它,發現一些東西暗示它是php版本,但此后我做了更改,因此實時服務器和測試服務器均為5.4。
誰能引導我正確的方向?
[]
是數組聲明的簡短語法,如果測試服務器的PHP 5.4或更高版本,它應該可以工作。
如果由於某種原因問題仍然存在,請嘗試將代碼更改為此:
// [today]
function today_func( $atts ) {
// Retrieve current days schedule
$today = getdate();
$query = new WP_Query( array(
'post_type' => 'day_entry',
'year' => $today["year"],
'monthnum' => $today["mon"],
'day' => $today["mday"] ,
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
) );
$day_type = $query->post->day_type;
$query = new WP_Query( array('post_type' => 'day_type','name' => $day_type) );
return $query->post->post_content;
}
add_shortcode( 'today', 'today_func' );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.