您可以将筛选器挂接到post_thumbnail_html 并检查其是否属于该类别的帖子,以及用户是否未登录,例如:
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;
}