• nepf

    (@nepf)


    Ich want to display the link to the newest attachment of the Page ID 215 in the sidebar.
    I tried this code

    <?php query_posts('page_id=215');?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <?php echo wp_get_attachment_url(); ?>
    <?php endwhile; endif; ?>

    But nothing.
    What ist wrong? Any help?

Viewing 1 replies (of 1 total)
  • esmi

    (@esmi)

    Not tested but try:

    <?php
    $images =& get_children( 'post_parent=215&post_type=attachment&post_mime_type=image' );
    foreach ( $images as $image_id => $image ) {
    	echo wp_get_attachment_image( $image_id, 'thumbnail' );
    	break;
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Display attachment-link in sidebar’ is closed to new replies.