I’d like to be able to remove post dates on posts of a given category and have the date show on all other posts.
Let me explain.
We have a list of shows we are going to attend. Here for example: https://reflexphotonics.com/ieee-avfop/
On the post page, the date of these posts is the date of creation which bears no relation to the date of the show itself.
I found that confusing, so I removed the date from the posts (appearance>customize>theme settings…).
The problem now is that all other posts (news, announcements…) have no date..
All my show post have a category and a sub-category appended to them (tradeshow-2019; q3-q4) in order to show on this page: https://reflexphotonics.com/company/tradeshow_events/
Is there a way to do have the date show selectively on post pages ?
Removing post date on post of a given category
Hi JF
Yes, we can do this. I’ll come back to you with a solution.
I’ve added the function here. You can paste the function into the plugin Code Snippets as a new snippet. If you do so, select the option to run the snippet on the site front-end then save and activate. Alternatively, the function can be inserted into a child theme functions.php file. The only line that needs to be changed is:
if ( ! in_category( '1' ) ) {
1 needs to be changed to the ID of the category to exclude the date from. Go to Posts > Categories, edit the category in question and check the URL to locate the category ID.
You’ll also need to re-enable the theme setting to display the post date.
Brilliant !
One last thing… how do have this work on more that one category concurrently (“tradeshow-2019” and “tradeshow-2020”) for example.
The line reads like this:
if ( ! in_category( ‘492’ ) ) {
492 is the category ID for “tradeshow-2019”
642 is the category ID for “tradeshow-2020”
Resolved !
Thanks again for the prompt response and help.
For sure, glad to hear that helped 🙂