Removed Year but Month and Day remains
-
Hi I’m using the Enigma theme and your plugin removes the year (which is great) but not the month or day – any ideas?
-
Hey Philip,
FYI, as a best practice here on the forums, always include your URL so that we can see it to help figure out what’s going on.
But since Enigma is a free theme, I downloaded it on my development site to get to the bottom of it.
It’s making the day disappear, but not the month and year.
To make your date disappear (it’ll remove the entire colored box unless you add some theme modifications), you’ll add the following li class to the OPDRstyle.css file at yoursite.com/wp-content/plugins/wp-old-post-date-remover/css/:
li.enigma_post_date
Add it at the beginning of the list of classes, like so:
li.enigma_post_date, .entry-date, post-date, span.post-date, span.date, .entry-time, span.post_date, span.post_date_intro { display:none !important; }
Future updates to the plugin will include this class, so you’ll be good to update the plugin without breaking anything.
Let me know if you need anything else.
Don’t forget to rate and donate to plugins that are awesome and free.
Sorry about best practice – first time I’ve ever used forums
Thanks for your quick response. I did exactly as you suggested and it works a treat for the post (and I really don’t mind the fact that the blue box disappears) – https://www.soulaction.co.za/staff-team/
However, the date is still there in the category that the page is in – https://www.soulaction.co.za/about/team/
Thanks for your assistance thus far
Phil
Hey Phil,
Yeah, I can tell I’m gonna need to clarify that this plugin only works on individual posts. It doesn’t affect lists (categories or the home page) pages at all.
You are the third one who has asked about this. ??
The plugin only removes the date from single posts. Category pages, archives, and the home page are not affected.
In the case of your specific theme, I’d reach out to the theme developer to see the best way to remove the date from category pages/posts.
In my quick perusal of the theme, it would be easy to remove the entire block (all of line 3) from post-content.php, but I think that would remove the date from EVERYTHING, not just older stuff.
LAST MINUTE CHANGE: I wrote this whole reply, and then figured out that you can erase the date on entire category archive pages by changing some code in my plugin, with some caveats.
On line 40 of ../plugins/wp-old-post-date-remover/wp-old-post-date-remover.php you can replace the code with
if ( $difference >= $OPDRinput && (is_single() || is_archive())) {
This makes it such that all category pages will hide the date, based on the date of the most recent post in that category. So if you’ve chosen a period of 5 days in the settings for my plugin and have a category where the most recent post is 6 days old, none of the dates will show on the category page. If the most recent post is 4 days old for that category, it will display the date on ALL posts on that category archive (unless you are looking at the individual post, where my plugin will still behave as normal.)
Note: never update php files from within the WordPress dashboard, because if you make a mistake, you can’t get back to it to fix it. Always use FTP and a text editor.
I am going to test this new line of code on some other themes to determine if it’s something that can be an official release of my plugin, but for now you can make that change and your site should be good to go!
Thanks for the opportunity to learn something!
SO JUST SO I’M CLEAR
if ( $difference >= $OPDRinput && is_single() ) {
CHANGES TO
if ( $difference >= $OPDRinput && (is_single() || is_archive())) {
IS THAT CORRECT? I’M BIT CONFUSED ABOUT LINE NUMBERS, AS I MAKE THAT LINE 42
Hey Phil,
You’re right, my bad. It is line 42 in the plugin file (I had been messing around with mine and forgot I wasn’t dealing with the public file.
And yes, those two lines should be changed out.
Let me know if you need anything else. Thanks again!
Sorry, you’re going to get fed up of me – made the change and WP said:
This plugin has been deactivated because your changes resulted in a fatal error.
Parse error: syntax error, unexpected ‘;’ in /mounted-storage/home9c/sub001/sc18540-NNWS/soulaction.co.za/wp-content/plugins/wp-old-post-date-remover/wp-old-post-date-remover.php on line 42
No, I’m not fed up. ??
That means that your copy paste messed up the php file somehow. The error says there is an extra semicolon somewhere.
Here’s the entire file to cut and paste for you ??
Perfect!
Thanks for your assistance and patience
- The topic ‘Removed Year but Month and Day remains’ is closed to new replies.