ummm no , voy por otro lado mira
$parent ="";
$link="Esta es el limk";
function get_images_from_media_library() {
$args = array(
'post_type' => 'attachment',
'post_mime_type' =>'image',
'post_status' => 'inherit',
'posts_per_page' => 16,
'orderby' => 'date',
'post_parent' => $post->ID
);
$attachments = get_posts( $args );
global $parent;
global $link;
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
//echo apply_filters( 'the_title', $attachment->post_title );
//the_attachment_link( $attachment->ID , false );
get_post_field( 'post_parent', $attachment->ID);
$link = get_permalink($parent);
//$image_attributes = wp_get_attachment_image_src( $attachment_id ); obtener la url de la imagen.
//$postURL = explode("attachment",get_permalink($post->ID)); para obtener el link del post por medio de explode.
}
}
$query_images = new WP_Query($args);
$images = array();
foreach ( $query_images->posts as $image) {
$images[]= $image->guid;
}
return $images;
}
function display_images_from_media_library() {
global $link;
$imgs = get_images_from_media_library();
$html = '<div id="media-gallery">';
foreach($imgs as $img) {
$html .= '<img src="' . $img . '" alt="'.$link.'" />';
}
$html .= '</div>';
$link=NULL;
return $html;
}
La idea es mostrar las ultimas fotos que se han subido al wordpress y enlazarlas con su post padre.