0

I am building a theme that includes the featured image as a navigation feature outside the single post, but once the user gets to the post in category "Specials", I'd like to take that image away. None of the other category posts require this lack of Featured Images. Theirs can be intact.

I can do it with JavaScript easily enough, targeting the div, but I'd like to do it server-side.

How can I isolate and remove a featured image from a specific category's posts?

1

Something like this ought to work, in your single.php or whatever:

if(is_single() && has_term('specials', 'my_taxonomy', $post)){
    // do something not thumbnail-related
} else {
    the_post_thumbnail();
}

Not sure what your taxonomy is.

  • There isn't the_post_thumbnail in this file, though. The whole post is like this, in a while loop: get_template_part( 'content', get_post_format() ); – Smittles Aug 12 '13 at 18:31
  • Well, then go deeper into the rabbit hole and modify the part that was mentioned. Sounds like there may be multiple files.... 'content-aside.php', 'content-blah.php' or something. Somewhere, a thumbnail function is being called. – GhostToast Aug 12 '13 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.