Wordpress
 

Wordpress

Codeschnipsel

Bilder zu einem Artikel anzeigen

<?php 
$images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent='.$post->ID);
 
if ( empty($images) ) {
    // No images found
} else {
    foreach ( $images as $attachment_id => $attachment ) {
        $image = wp_get_attachment_image_src( $attachment_id, 'full' );
        echo '<img src="'.$image[0].'" alt="">';
    }
}	
?>

Hinweis: Es erlaubt nur Zugriff auf Breite, Höhe und SRC des Bildes, nicht auf Alternativtexte (Die hat es aber im konkreten Anwendungsfall nicht gebraucht).

web/wordpress.txt · Zuletzt geändert: 24.03.2009 12:23 von yatil
 
 
Impressum, Inhalte stehen unter einer Creative Commons Lizenz.