How to show only 1 picture in gallery
-
The official premium forum page is showing up in bad shape and so I can’t post anything! I sent an email via the contact us link which says I would get a confirmation email that the email was sent and no email at all. I hope you can read my email. I was asking if it was possible to modify the loop so that only one image from the gallery is shown and when you click on it, you get the pretty photo lightbox showing all the images of the gallery. As I see there is no way to add gallery per photo category, this is the only way I have imagined we could display a gallery. I have tried it myself by adding a counter to the loop on responsive-photo-gallery-short-code.php :
/** * Load All Image Gallery Custom Post Type */ $IG_CPT_Name = "rpgp_gallery"; $AllGalleries = array( 'p' => $Id['id'], 'post_type' => $IG_CPT_Name, 'orderby' => 'ASC' ); $loop = new WP_Query( $AllGalleries ); ?> <div class="gal-container <?php if ( $WL_Light_Box == "lightbox2" ) { echo "photobox-lightbox_$RPGP_Id"; } ?> "> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php static $count = 0;?> <!--get the post id--> <?php $post_id = get_the_ID(); ?> <?php if ( $WL_Show_Gallery_Title == "yes" ) { ?> <!-- gallery title --> <div class="rpgp-gallery-head"> <?php echo get_the_title( $post_id ); ?> </div> <?php } ?> <div class="gallery1" id="weblizar_<?php echo get_the_ID(); ?>"> <?php /** * Get All Photos from Gallery Details Post Meta */ get_the_ID(); $RPGP_AllPhotosDetails = unserialize( base64_decode( get_post_meta( get_the_ID(), 'rpgp_all_photos_details', true ) ) ); $TotalImages = get_post_meta( get_the_ID(), 'rpgp_total_images_count', true ); $i = 1; foreach ( $RPGP_AllPhotosDetails as $RPGP_SinglePhotoDetails ) { $name = $RPGP_SinglePhotoDetails['rpgp_image_label']; $url = $RPGP_SinglePhotoDetails['rpgp_image_url']; $url_full = $RPGP_SinglePhotoDetails['rpgp_image_url']; $url1 = $RPGP_SinglePhotoDetails['rpgp_12_thumb']; $url2 = $RPGP_SinglePhotoDetails['rpgp_346_thumb']; $url3 = $RPGP_SinglePhotoDetails['rpgp_12_same_size_thumb']; $url4 = $RPGP_SinglePhotoDetails['rpgp_346_same_size_thumb']; $i ++; if ( $WL_Gallery_Layout == "col-md-12" ) { // one column $Thummb_Url = $url; } if ( $WL_Gallery_Layout == "col-md-6" ) { // two column if ( $WL_Thumbnail_Layout == "same-size" ) { $Thummb_Url = $url3; } if ( $WL_Thumbnail_Layout == "masonry" ) { $Thummb_Url = $url1; } if ( $WL_Thumbnail_Layout == "original" ) { $Thummb_Url = $url; } } if ( $WL_Gallery_Layout == "col-md-4" || $WL_Gallery_Layout == "col-md-3" || $WL_Gallery_Layout == "col-md-2" ) {// 3 4 6 column if ( $WL_Thumbnail_Layout == "same-size" ) { $Thummb_Url = $url4; } if ( $WL_Thumbnail_Layout == "masonry" ) { $Thummb_Url = $url2; } if ( $WL_Thumbnail_Layout == "original" ) { $Thummb_Url = $url; } } ?> <div class="<?php echo $WL_Gallery_Layout; ?> col-sm-6 wl-gallery"> <div class="b-link-<?php echo $WL_Hover_Animation; ?> b-animate-go"> <?php if ( $WL_Show_Image_Lightbox == "yes" ) { ?> <img src="<?php echo $Thummb_Url; ?>" class="gall-img-responsive" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>"> <div class="b-wrapper"> <?php if ( $WL_Gallery_Layout == "col-md-12" || $WL_Gallery_Layout == "col-md-6" || $WL_Gallery_Layout == "col-md-4" ) { ?> <?php if ( $WL_Show_Image_Label == "yes" ) { ?> <h2 class="b-from-left b-animate b-delay03"> <div class=" rpgp-header-label"><?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?></div> </h2> <?php } ?> <?php } //photobox if ( $WL_Light_Box == "lightbox2" ) { ?> <p class="b-from-right b-animate b-delay03"> <a href="<?php echo $url; ?>" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>"> <i class="<?php echo $WL_Image_View_Icon; ?> <?php echo $WL_Image_View_Icon_Size; ?>"></i> <img src="<?php echo $Thummb_Url; ?>" class="gall-img-responsive" style="display:none !important; visibility:hidden" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>"> </a> </p> <?php } //nivo box if ( $WL_Light_Box == "lightbox1" ) { ?> <p class="b-from-right b-animate b-delay03"> <a data-lightbox-gallery="enigma_lightbox" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>" class="nivoz_<?php echo $RPGP_Id; ?>" href="<?php echo $url_full; ?>"> <i class="<?php echo $WL_Image_View_Icon; ?> <?php echo $WL_Image_View_Icon_Size; ?>"></i> </a> </p> <?php } // 3 - pretty photo Box if ( $WL_Light_Box == "lightbox3" ) { ?> <p class="b-from-right b-animate b-delay03"> <a class="portfolio-zoom icon-resize-full" data-rel="prettyPhoto_<?php echo $RPGP_Id; ?>[portfolio]" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>" href="<?php echo $url; ?>"> <i class="<?php echo $WL_Image_View_Icon; ?> <?php echo $WL_Image_View_Icon_Size; ?>"></i> </a> </p> <?php } // 4 - Swipe Box if ( $WL_Light_Box == "lightbox4" ) { ?> <p class="b-from-right b-animate b-delay03"> <a title="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>" class="swipebox_<?php echo $RPGP_Id; ?>" href="<?php echo $url_full; ?>"> <i class="<?php echo $WL_Image_View_Icon; ?> <?php echo $WL_Image_View_Icon_Size; ?>"></i> </a> </p> <?php } ?> </div> <?php } else { //photobox if ( $WL_Light_Box == "lightbox2" ) { ?> <a href="<?php echo $url; ?>" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>"> <img src="<?php echo $Thummb_Url; ?>" class="gall-img-responsive" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>"> <div class="b-wrapper"> <?php if ( $WL_Gallery_Layout == "col-md-12" || $WL_Gallery_Layout == "col-md-6" || $WL_Gallery_Layout == "col-md-4" ) { ?> <?php if ( $WL_Show_Image_Label == "yes" ) { ?> <h2 class="b-from-left b-animate b-delay03 rpgp-header-label"><?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?> </h2> <?php } ?> <?php } ?> </div> </a> <?php } // nivobox if ( $WL_Light_Box == "lightbox1" ) { ?> <a data-lightbox-gallery="enigma_lightbox" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>" class="nivoz_<?php echo $RPGP_Id; ?>" href="<?php echo $url; ?>"> <img src="<?php echo $Thummb_Url; ?>" class="gall-img-responsive" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>"> <div class="b-wrapper"> <?php if ( $WL_Gallery_Layout == "col-md-12" || $WL_Gallery_Layout == "col-md-6" || $WL_Gallery_Layout == "col-md-4" ) { ?> <?php if ( $WL_Show_Image_Label == "yes" ) { ?> <h2 class="b-from-left b-animate b-delay03 rpgp-header-label"><?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?> </h2> <?php } ?> <?php } ?> </div> </a> <?php } // pretty photo if ( $WL_Light_Box == "lightbox3" ) { ?> <a class="portfolio-zoom icon-resize-full" data-rel="prettyPhoto_<?php echo $RPGP_Id; ?>[portfolio]" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>" href="<?php echo $url; ?>"> <img src="<?php echo $Thummb_Url; ?>" class="gall-img-responsive" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>"> <div class="b-wrapper"> <?php if ( $WL_Gallery_Layout == "col-md-12" || $WL_Gallery_Layout == "col-md-6" || $WL_Gallery_Layout == "col-md-4" ) { ?> <?php if ( $WL_Show_Image_Label == "yes" ) { ?> <h2 class="b-from-left b-animate b-delay03 rpgp-header-label"><?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?> </h2> <?php } ?> <?php } ?> </div> </a> <?php } // swipe box if ( $WL_Light_Box == "lightbox4" ) { ?> <div id="swipebox-title"> <a title="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>" class="swipebox_<?php echo $RPGP_Id; ?>" href="<?php echo $url; ?>"> <img src="<?php echo $url_full; ?>" class="gall-img-responsive" alt="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>" title="<?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?>"> <div class="b-wrapper"> <?php if ( $WL_Gallery_Layout == "col-md-12" || $WL_Gallery_Layout == "col-md-6" || $WL_Gallery_Layout == "col-md-4" ) { ?> <?php if ( $WL_Show_Image_Label == "yes" ) { ?> <h2 class="b-from-left b-animate b-delay03 rpgp-header-label"><?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?> </h2> <?php } ?> <?php } ?> </div> </a> </div> <?php } } ?> </div> <?php if ( $WL_Show_Image_Label == "yes" ) { ?> <h4 class="rpgp-footer-label"><?php echo html_entity_decode( $name, ENT_QUOTES, "UTF-8" ); ?></h4> <?php } ?> </div> <?php } ?> </div> <?php if ($count == "1") { break; } $count++; ?> <?php endwhile; ?> </div>
but it does nto work, it is still showing up all images of the gallery. Could you provide a way? thanks
The page I need help with: [log in to see the link]
- The topic ‘How to show only 1 picture in gallery’ is closed to new replies.