You can hook a filter to the post_thumbnail_html
and check if its a post in that category and if the user is not logged in ex:
add_filter( 'post_thumbnail_html', 'my_post_image_html_wpa92119', 10, 3 );
function my_post_image_html_wpa92119( $html, $post_id, $post_image_id ) {
$category_to_exclude = "CHANGE_WITH_CATEGORY ID";
$logIn_Img_path = "CHANGE THIS WITH PATH/TO/NON-LOGGED/USERS/IMAGE";
//check if the post have that category nad if the user is not logged in
if (has_category( $category_to_exclude ) && !is_user_logged_in())
return '<a href="'.wp_login_url( get_permalink($post_id) ).'"><img src="'.$logIn_Img_path.'" alt="please log in"></a>';
//if you got here then he is either logged in or its not the specified category
return $html;
}
Related Posts:
- Conditional: IF current author’s custom post has a post thumbnail
- How to get image title/alt attribute?
- How to set featured image to custom post from outside programmatically
- Generate Thumbnails only for Featured Images
- How to add post featured image to RSS item tag?
- Get featured image URL by page id
- wp_get_attachment_image_src() and custom sizes
- What’s the difference between post thumbnails and featured images (if any)?
- What is your take: TimThumb vs. WordPress Thumbnails? The great debate [closed]
- How to change the naming of the resized image files
- How to get featured post title & image using JSON API?
- Display thumbnail only on the very first post in the loop?
- Allow user to manually set crop area of default/custom image sizes on upload [closed]
- Display child pages on a parent and child page using Featured Thumbnails
- How to display a post’s Featured Image with this code?
- Conditional to grab parent page thumbnail URL
- Show featured image in sidebar
- Featured Image VS Post_thumbnail — has_post_thumbnail lies?
- Use get/the_post_thumbnail with Custom Size & Crop
- The Thumbnail aspect Ratio Issue
- Cropped thumbnail still displaying as full image
- Use Video as Featured Image
- Media thumbnail for custom post inside post content
- Why am I getting errors in product.thumbnails.php? [closed]
- featured image metabox not showing on the default post types edit page
- Featured image always rendered with 198px of height?
- How to retrieve the post featured image (thumbnail) ID in Gutenberg blocks?
- MultiPostThumbnail and the_post_thumbnail
- Featured image is not uploading
- how to use the new image size
- Image still attached to post even after removing it as featured image
- Create custom thumbnail size on existing posts
- thumbnails are getting clipped down, want to resize instead
- Multiple Post thumbnails (at least three)
- How check that there is post thumbnail feature image or not on wordpress?
- Force WordPress to strip/remove EXIF/IPTC metadata when resizing thumbnails
- How to offset thumbnails to the center?
- Secondary Featured Image Function (post_thumbnail)
- Retrieve post thumbnail as array
- Single post layout based on featured image size
- Migrating problem – featured images
- Set Featured Image by URL Form Post
- Adding Images into API
- Stuck on save/upload featured images plugin
- adaptive featured images wordpress 4.4 grid
- ACF – Add/update featured image (for videos) by field [closed]
- Forcing a user to crop the featured image in a certain aspect ratio
- oEmbed, thumbnails and wordpress
- Show last 2 image attachments from posts
- Set featured image from external URL
- Show Multiple Size URL of one Featured Image/Thumbnail?
- remove and disable image link in functions.php
- Get current post featured image ID
- Why does the_post_thumbnail output full sized images after activating post-thumbnails support?
- Can this be done? Create 50×50 thumbnails of all existing featured images?
- Query to delete all featured images and remove post meta?
- How to bring files from the upload directory to the media gallery?
- Add Image Size for Featured Image with Responsive Design
- Best Way to Display Posts by Tag (not category)
- WordPress image crop probems
- Pull through featured image in a custom menu
- How do I get posts where image is larger than…?
- Category page with thumb is ok but can’t do the same with tags
- Programmatically set thumbnail via URL using DOM and XPATH – Where to add ELSEIF
- Retrieve a post’s featured image with PHP outside of WordPress
- Better way to show Description and image Captions
- Different size thumbnails on home and single pages
- Next Prev Post link rendering current post thumbnail
- How to add thumbnail images? (Set Featured Image doesn’t work)
- custom image size not being fetched
- Resizing images failing
- How to add a new thumbnail size only to a certain custom post type?
- Tag,php – how to get it to display featured post image? [closed]
- Featured images have disappeared in the Trending section only of my website
- Blog replace single post page featured image
- How to use tag in featured image
- How to automatically add first image of post as thumbnail?
- Change wording of default thumbnail metabox
- featured image metabox not moving custom post type
- How to convert feature image as background image
- about featured image
- Moving Featured Images
- Add Play Icon on thumbnail overlay for video post types
- How do I Get WordPress Featured image from Frontend
- Featured Image, and Image in post
- Get Post thumbnail without width/height attribute
- if statement for featured images
- Thumbnail size according to width and height
- Featured Image URL is Showing but not thumbnail
- Custom image sizes are not used
- Import Dummy Content and Post Thumbnails
- Source problem for children page image
- Fetch first image URL from post and set as featured image URL
- How to set featured image from a variable
- How to stop WordPress from creating native thumbnails?
- get_post_thumbnail_id() not getting correct featured image after post edited
- the_ID & wp_get_attachment_image_src(the_ID(), “medium”) blank
- How to I remove Featured Image from the Posts/Category Lists?
- How do I change the size of the feature picture of a single post?
- Close featured image modal windows with JS