Forums

post image attachments to make a post gallery (2 posts)

  1. danielhpark
    Member
    Posted 3 months ago #

    How do you make image pulled from post attachments to make a image gallery like this?

    <img src="http://hellotokyostore.com/docs/help.gif" />
    http://hellotokyostore.com/docs/help.gif

    *Need “if” condition.. showing no images if there are no uploaded images for the post.

  2. danielhpark
    Member
    Posted 3 months ago #

    so for i got something like this:

    <?php global $post;
    			$args = array(
    			'post_parent' => $post->ID,
    			'post_type' => 'attachment',
    			'post_mime_type' => 'image',
    			'orderby' => 'menu_order',
    			'order' => 'ASC',
    			'offset' => '1',
    			'numberposts' => 1 );
    			$images = get_posts($args);
    				if ($images) {
    				$i = 0;
    			?>
    			<a href="/"><?php echo wp_get_attachment_image( $images[$i]->ID, 'full' ); $i++; ?></a>
    			<?php } else { ?>
    			<img src="<?php bloginfo('template_url') ?>/images/thumb-bg.png" />
    			<?php } ?>

    But I can't seem to link it to the attachment

Reply

You must log in to post.

About this Topic