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 Answer 1

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.

2
  • 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() );
    – Jon Mitten
    Aug 12, 2013 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, 2013 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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