Per ogni post del mio blog possiedo una featured image, e una seconda attachment image. Dunque due immagini per ogni post. La prima è semplice da richiamare. Per la seconda mi ci son dovuto ammazzare facendo ricerche su ricerche, ed alla fine son riuscito ad estrapolarla mediante un lungo codice da inserire nel file functions.php
Eccolo:
Codice PHP:
function haruki($post_id) {
global $post;
$thumbnail_ID = get_post_thumbnail_id();
$images = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
if ($images) :
foreach ($images as $attachment_id => $image) :
if ( $image->ID != $thumbnail_ID ) :
$img_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); //alt
if ($img_alt == '') : $img_alt = $image->post_title; endif;
$big_array = image_downsize( $image->ID, 'large' );
$img_url = $big_array[0];
echo $img_url;
endif; endforeach; endif; }
Dopodiché richiamo l'immagine nei post utilizzando semplicemente
Codice PHP:
<?php haruki("$post->ID"); ?>
Tuttavia sono convinto che debba per forza esistere un metodo più semplice e rapido di ottenere sto benedetto link, magari senza dover necessariamente passare per functions.php
Qualcuno mi sa aiutare?
Qui c'è una spiegazione approfondita (che io non ho purtroppo le competenze di capire, visto che sono un newbie per ora):
https://developer.wordpress.org/refe...ent_image_src/