Support » Plugins » Hacks » Hide featured image if post format is gallery

  • wpni

    (@wpni)


    Currently creating a custom base theme, on single.php I am showing the featured image at the default 150px x 150px size, it is right aligned within the post.

    My code looks like this:

    <?php
    			if ( has_post_thumbnail() ) {
    				$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'big-thumb' );
    				echo '<a rel="lightbox" href="' . $large_image_url[0] . '" title="' . the_title_attribute( 'echo=0' ) . '">';
    				the_post_thumbnail( 'thumbnail', array( 'class' => 'post-thumb' ) );
    				echo '</a>';
    			}
    		?>
    
    		<?php the_content(); ?>

    However I want to place a statement to hide the post_thumbnail IF the post format is gallery. What would I add to either the content-single.php or functions file?

Viewing 2 replies - 1 through 2 (of 2 total)
  • ikaring

    (@ikaring)

    How about changing

    if ( has_post_thumbnail() )

    to

    if ( has_post_thumbnail() && "gallery" != get_post_format() )

    Thread Starter wpni

    (@wpni)

    This is probably not the correct solution, but the following has worked – I think I may have been over-complicating the problem.

    .format-gallery .post-thumb {
    	display:none;
    }

    A simple bit of CSS, however I am not a huge fan of using ‘display:none;’

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide featured image if post format is gallery’ is closed to new replies.