Error de sintaxis de Wordpress, inesperado [
Tengo un problema con una instalación de wordpress. Cuando trabajo localmente, esta función funciona correctamente:
function get_images_from_media_library() {
$args = array(
'post_type' => 'attachment',
'post_mime_type' =>'image',
'numberposts' => -1,
'post_status' => null,
'post_parent' => null, // any parent
);
$attachments = get_posts($args);
$images = array();
if ($attachments) {
foreach ($attachments as $post) {
setup_postdata($post);
array_push($images, wp_get_attachment_image_src($post->ID, 'full')[0]);
}
}
return $images;
}
Esto recupera todas las imágenes adjuntas a los medios en la instalación y las devuelve en una matriz.
Sin embargo, cuando instalo mi instalación en mi sitio remoto, recibo este error cuando intento usar el tema que contiene esta función:
Parse error: syntax error, unexpected '[' in /hermes/bosoraweb133/b2623/ipg.yourdomaincom/98EMcBee/wp-content/themes/98emcbee/functions.php on line 52
La línea 52 es esta línea dentro del foreach:
array_push($images, wp_get_attachment_image_src($post->ID, 'full')[0]);
¿Por qué obtendré este error en un sitio remoto y no en un sitio local?