2016-01-05 44 views
0

分配我用這種方式來獲取圖像後,如:WordPress的:只有變量應參考

$images =& get_children('post_type=attachment&post_mime_type=image&post_parent='.get_the_ID()); 

的工作不錯,但給我看在控制檯此錯誤: 只有變量應該參考指派

如何解決?

+0

你試過了:'$ images = get_children('post_type = attachment&post_mime_type = image&post_parent ='。get_the_ID());'? – Milap

+0

您可以通過引用變量,新語句或從函數返回的引用傳遞。閱讀更多[這裏](http://php.net/manual/en/language.references.pass.php)。只要刪除'&',你就可以在'$ images'變量中得到你可以使用的數組。 –

+0

是的,它的工作,,, thankx –

回答

0

錯誤來自wordpress強制執行E_STRICT規則後面的PHP配置。 你只能通過函數引用返回變量 - 沒有別的。

更多關於如何改變你的php.ini文件(隱藏警告,但沒有解決的原因) https://secure.php.net/manual/en/migrating5.errorrep.php

這裏更多,包括你在這裏做什麼(我覺得)的例子 - 。