• I create slideshow in single-post and check if have only 1 image is show 1 image, but if have images it will show slide then can click button prev and next.

    Problem is:
    I don’t want to show image or exclude image from post content in slideshow when choose insert into post.

    This my code:

    <?php while(have_posts()) : the_post(); ?>
    	<?php
    
    		// Check single post have attachment image if not use thumbnail
    		$thumb_ID = get_the_post_thumbnail( $post->ID );
    		$images = get_posts(array(
    			'post_parent' => $post->ID,
    			'post_type' => 'attachment',
    			'numberposts' => -1,
    			'post_mime_type' => 'image',
    			'exclude' => $thumb_ID,
    		));
    
    		if (count($images) > 1) {
    			echo '<ul id="mycarousel" class="jcarousel-skin-tango">';
    			foreach( $images as $image ) {
    				$attachmenturl = wp_get_attachment_url($image->ID);
    				$attachmentimage = wp_get_attachment_image_src( $image->ID, 'loop_image');
    				echo '<li><img src="' . $attachmentimage[0] . '" /></li>';
    			}
    			echo '</ul>';
    		} else {
    			echo '<div id="entry_image">';
    				the_post_thumbnail('loop_image');
    				echo $images;
    			echo '</div>';
    		}
    
    		if($image != '') {
    			echo '<div id="big_slide_control">';
    			echo '<a href="" id="big_slide_prev"></a><a href="" id="big_slide_next"></a>';
    			echo '</div>';
    		}
    	?>
    <?php endwhile; ?>

  • The topic ‘How to hide image when insert into post?’ is closed to new replies.