Hide Photos tab (gallery) if only 1 image

This topic contains 9 replies, has 3 voices, and was last updated by  Foster 5 years ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #516515

    Foster
    Full Member
    Post count: 164

    Hello,

    In my setup I have a

      single

    Featured image for most listings. Is there a way to hide the Photos tab if the only image is the Featured image? The featured image is already shown in the header, if there are no additional images, the Photos tab just takes up space.

    I tried the Shortcode builder approach but did not see the combination of settings to do what I want.

    Maybe there’s a CSS or snippet?

    #516521

    Guust
    Moderator
    Post count: 29970

    I’ll check with the developers to see if there is a simple solution for this.
    Thanks

    #516607

    Naveen Giri
    Moderator
    Post count: 1559

    Hi,

    You can try following js code to hide it.
    https://wpgeodirectory.com/docs-v2/faq/customizing/#snippets

    
    jQuery(document).ready(function(){
    	if ( jQuery('.geodir-image-wrapper ul.geodir-gallery li').length <= 1  ) {
    		jQuery('.geodir-tab-head *[data-tab="#post_images"]').hide();
    		jQuery('#post_imagesTab').hide();	
    	}	
    })
    

    Thanks

    #516637

    Foster
    Full Member
    Post count: 164

    Hi, thanks.
    I tried to create a new snippet in Code Snippets using by copy & pasting the code above but received the following error message:

    The code snippet you are trying to save produced a fatal error on line 0:

    Exception thrown without a stack frame

    #516675

    Guust
    Moderator
    Post count: 29970

    Use this code in Code Snippets:

    add_action( 'wp_head', function () { ?>
    	<script>
    
    		jQuery(document).ready(function(){
    	if ( jQuery('.geodir-image-wrapper ul.geodir-gallery li').length <= 1  ) {
    		jQuery('.geodir-tab-head *[data-tab="#post_images"]').hide();
    		jQuery('#post_imagesTab').hide();	
    	}	
    })
    
    	</script>
    <?php } );

    Thanks

    #516678

    Foster
    Full Member
    Post count: 164

    I’m sorry. That new snippet isn’t showing any error messages, but it also doesn’t seem to be working. The Photos tab still appears.

    #516680

    Guust
    Moderator
    Post count: 29970

    I guess you activated the snippet for the frontend.
    Please post your URL and WP admin details in a private reply and we’ll have a look at your settings if you like.
    Thanks

    #516686

    Foster
    Full Member
    Post count: 164
    This reply has been marked as private.
    #516689

    Naveen Giri
    Moderator
    Post count: 1559

    Hi Foster,

    seems html is different on your site. I have updated the code.
    please check now.

    Thanks

    #516766

    Foster
    Full Member
    Post count: 164

    Yes, it appears to be working now. Thank you.

Viewing 10 posts - 1 through 10 (of 10 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount