You could do this :
$categories = get_the_category($post->ID);
$cat = $categories[0]->cat_name;
if ( has_post_thumbnail() && $cat == 'news' ) { the_post_thumbnail('medium'); }
*EDIT: the code grabs the post category, line 2 grabs cat name from the object and I use it as a condition in if statement *
Related Posts:
- removing inline styles from wp-caption div
- Add custom Attachment Display Setting for images
- How to get Images included in Post
- disable WP automatically inserted line breaks after an image
- Find the post an attachment is attached to
- Delete the original big size image after upload and leave only 3 images crunched by media gallery
- Post slugs and images cannot have same name?
- Add existing images from Media Library in to custom gallery
- Replace image attributes for lazyload plugin (data-src)
- How do I detach images from posts?
- Download external images if post is publish
- How do I sort (order) the results from `get_children()`?
- upload image in a meta box
- Can I load posts via Ajax?
- How do I use element instead of tags in WordPress post content having webP support?
- How to remove images from showing in a post with the_content()?
- Unattaching images from a post
- how to display post content without post image?
- How to wrap every image in a post with a div?
- upload featured image from front end using wordpress add media button
- How do I create Comma Separated list of attached image ids?
- Get post embedded image caption
- how to grab first link in post… and of course call it
- Author Avatar as default first image
- Link post images to post
- How to get the next and previous image title from attachment or gallery?
- Attachment image single page
- How to change the order of elements within a post?
- Only show featured image on exerpt and exclude images in post
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- How to call WordPress First Image Post or else Attached Image or Default
- Regarding Posts
- how can display a post on home screen without images
- Changing The Default Header POST Title and Description text by category in wordpress
- Site/Post preview is not working on all social media
- How to exclude native lazy loading from first image in post content?
- Rewrite image links from attachment id to attachment link
- Delete media from the post but keep my featured image and post
- Aligning images in the wp editor not working. How do i get this to work in custom theme?
- unable to write to the database while uploading images
- Pinterest button shows image options from different posts
- Change the size of the featured image for post?
- Display image gallery if more than 1 image
- How do I fix broken links to images in imported posts’ post_content?
- Thumbnails and images in the blog post are not loading
- Modified core/image rendering not showing in posts – only on pages
- Post images are not displayed in media library
- Delete attached images from posts
- Blog featured images disappeared on my homepage
- Blog images not showing on homepage
- Center crop the feature image
- Schedule image post on download
- Add another feature image box
- ‘posts’ table should not store the absolute image path
- How to show category image if no featured image is set?
- How to make an image appear as a thumbnail in the blog post?
- Integrate video and iframe in a post type gallery
- Set featured image on creating new post
- Manipulating images inside post content
- how to create other sizes of original image in one go wordpress uploads
- Output wp_link_pages as raw url
- How can I alternate styling of images in a post? [closed]
- Embed image in post from external url
- Customizing individual images on posts
- Is possible to do this from function.php
- Stop images from being displayed on the front-end of the site
- Update all images url imported from HTML pages
- Relative Image Urls in Posts are starting from root – Not from WordPress Address (URL) at General Settings
- WordPress Media URLs?
- Featured Images link to post parent
- SQL query to remove first image in all posts
- WP Gallery Image Page Issue When 2 galleries share one image
- Latest news mini images
- Why can’t I see my attachment page information for an image?
- How would I attach media/images to a post based on a ID stored in a each post’s custom field
- How do I insert a custom field in a user submitted post?
- Only show posts with image and the correct ammount of posts in loop
- Assign custom class to post content images
- Extra Theme – Fit image inside of Featured Post Slider
- Post thumbnail height problem
- Get attachment if matches a variable
- Is there any SEO impacts on unattached vs attached images for a post in WordPress?
- Full width images within post content
- Import alt text in set_post_thumbnail
- Broken images after importing posts and opening in Gutenberg
- Search doesn’t display posts with images
- Displaying all images from a WordPress post (including media library)
- How to move all images in a post to a single gallery for a bunch of posts?
- Inside post image title has been posting as a post title on my main post page
- Download button under all images WordPress
- website images getting corrupt automatically
- Optimize blog that serves hundred of images and videos
- Images and menu links disapearing after saving
- Images being uploaded via WP Media are not attached even they are used by some CPT posts
- Redirection – bulk edit 404s to new tomain
- how to display the actual size of the picture in post
- WordPress portfolio posts: media not displaying if several images
- Set Featured Image of a post
- Is there a way to eliminate flyout menus when adding a post?
- How to delete Full Size options from post Add Media?