webyoda Posted July 20, 2022 Share Posted July 20, 2022 I have the following code: <?php } else if ( is_single() ) { if ( get_field("sf_page_image") ) { $featured_image_ID = get_field("sf_page_image")["ID"]; } else { $featured_image_ID = 272; } There is a placeholder image displaying now if there is no featured image. I want to remove the placeholder image and show only the title if no featured image is present. Quote Link to comment https://forums.phpfreaks.com/topic/315067-show-title-only-if-no-featured-image-is-present/ Share on other sites More sharing options...
webyoda Posted July 20, 2022 Author Share Posted July 20, 2022 Here's a sample of what I'm referring to. Quote Link to comment https://forums.phpfreaks.com/topic/315067-show-title-only-if-no-featured-image-is-present/#findComment-1598430 Share on other sites More sharing options...
Psycho Posted July 20, 2022 Share Posted July 20, 2022 Your question is not clear. When you say "I want to remove the placeholder image and show only the title if no featured image is present." are you saying that you just want the "text" part of the image above ("This is a draft post with a really long . . . ") to be displayed? If so, find that image on your server (i.e. image ID 272) and edit the image to remove the AT&T part of the image from the left side. However, if the "title" you are wanting to show is actual text, you can't do it within the code you shared. That code you showed determines an $featured_image_ID to use. Somewhere else in the code there is logic to use that image ID to display the appropriate image. What you could do is: 1. Make the else part of that code set $featured_image_ID to false 2. Find the part of the code that uses the $featured_image_ID and add a branch of code that will test if the value is false and, if so, shows the "title" text wherever it would get that from. Quote Link to comment https://forums.phpfreaks.com/topic/315067-show-title-only-if-no-featured-image-is-present/#findComment-1598432 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.