get_post_meta is your friend:
if ( has_post_thumbnail() ) {
if ( 'yes' == get_post_meta( $post->ID, 'NFSWEG', true ) ) {
echo '<img src="https://wordpress.stackexchange.com/questions/82422/YOUR-IMAGE-HERE">';
} else {
the_post_thumbnail(
array( 400, 400, true ),
array( "class" => "aligncenter featured_image" )
);
}
}
Related Posts:
- Move from old custom field to new post_thumbnails
- Is there a hook / action that is triggered when adding or removing a post thumbnail?
- Order posts by custom field and if custom field is empty return remaining posts
- Up/Down voting system for WordPress
- Calling Specific Pages with wp query Part II
- Loop through two different sets of custom fields
- How can I migrate all of my custom field thumbnails to the built-in post featured image?
- automatically set “Featured Image” the same as the og:i that is set in a custom field
- Front-end update_post_meta with ajax
- Adding a custom field or metabox to the post-thumbnail widget?
- How do I exclude posts by custom field value?
- Echo values from custom field outside loop php
- Deleted pages showing up when querying for child pages
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Calling custom fields for pages (not posts)
- Duplicate posts being displayed when querying Custom Fields
- Add url from Custom Field as ‘Featured Image’. Code not working
- Loop to display random posts only if a custom field matches category
- How can I show custom fields in the loop only to specific user roles?
- get_posts that match a user-specified value on a page
- Accessing loop functions (e.g the_title or the_content) from post ID
- Front-end editing with custom fields?
- Limit the number of acf content when displaying in post loop [closed]
- Is there a better way to list all database terms alphabetically?
- Change the main loop WordPress impact on the server?
- custom-meta-box checkboxes from loop won’t save
- How to show a post if was published less than two hours ago?
- List users by sum of all their posts’ custom field values
- Custom field as Slug
- For homepage images (for small business website), is it better to use custom fields or post_thumbnail?
- Custom Fields – How to create a list from multi-line entries of a single value
- How to mass update custom fields for more than 20k posts
- Custom Query based on custom field of a single post
- Efficiently sort only certain categories by custom field
- Can I access a post meta field before the loop?
- Displaying page image in the footer automatically
- Can I use a Custom Field as the Featured Image URL?
- Show image if author meta (profile fields) exists outside loop
- Getting the Featured image URL and inserting it as Custom Field on Post update / publish
- Can’t query by meta_key
- frontend submit post jQuery clone row won’t save
- Advanced Custom Fields and Post Meta Fields Relation
- Front end register with custom fields
- Front-End User Profile
- ul list with only as many li’s as filled custom fields
- User customising position of WordPress Featured Image
- Set featured image from custom field URL
- Custom field as featured image caption
- Woocommerce frontend edit custom fields
- Loop through incrementing custom fields
- do_shortcode close
- Search Results Page – Displaying Custom Meta Fields
- How to insert multiple checkbox values into post as custom fields from frontend
- WP Insert post with post_thumbnail
- Custom field image to Featured Image
- Modify custom field from front end
- Interrogate a page within a loop to check template type or custom meta data (Pages vs Posts)
- Collect Data from NEXT item while in loop
- Adding extra fields to front end signup form
- Problem uploading different files as custom fields with front end post form
- How to show content of custom fields in search results?
- Custom field outside the loop and inside an array
- Selectively hiding or allowing thumbnails of featured images on front page
- Display metabox title for custom fields with values
- use custom field value as post category in loop
- Filter or order based on custom field
- Compare ACF date field (if exists) and post date and order DESC
- What am I missing in this Code Block?
- get_field values for each post on home page using wp_add_inline_style
- Let any visitors delete a post if they know Id nr & password?
- use custom field value as featured image
- Can you generate a featured image from two images from custom fields?
- User Filter Options on Archive Page
- How do I display a custom field in an existing form on the front end?
- How do I update custom field post meta in frontend post template?
- Custom meta boxes – add php code inside?
- get wordpress post loop by meta box date
- Outputting custom field on home.php not outside of blog list
- Use a different catalog image than the featured image
- Counting number of images from loop
- Metabox value for post loop?
- Automatically set the_post_thumbnail to Custom Field Value
- Get meta value when the page is a blog archive
- WP_query returns error when used for custom widget
- Related post thumbnail not showing up
- How to allow user to add to, but not edit, a post?
- Post thumbnail size for custom field only
- I want my post to republish again after adding a custom field
- Display posts where date field matches current month?
- Filtering posts by WORD in custom field
- Retrieve IDs from custom field, count and display results differently according to count
- Pagination not displaying correct number of pages
- Display custom field outside the loop
- How to mark a image attachment as background image?
- Custom field for image, not showing image!
- Custom field not showing
- Order by a meta field in query loop
- Show/Hide Featured Image or replace it with custom field [closed]
- Crop custom image size vs actual size
- get_the_ID() retrieves same ID on Gutenberg’s Query Loop