If/else statement not working as expected
-
Hello! First off thanks for any support given. It’s much appreciated!
I have the following code:
<?php if (class_exists('Dynamic_Featured_Image')) { global $dynamic_featured_image; $featured_images = $dynamic_featured_image->get_featured_images( $postId ); foreach( $featured_images as $image ) { echo "<img src='{$image['full']}' alt='Dynamic Featured Image' />"; } } else { echo wp_get_attachment_image( '7457', 'full' ); //fallback single image } ?>It appears that the class Dynamic_Featured_Image exists even if there’s not a 2nd featured image. Therefore my fallback image in the else statement does not display. How can I check if the class exists AND if there is a 2nd featured image set?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘If/else statement not working as expected’ is closed to new replies.