Show New Text on Post with last 72 hours

Hi there,

I am a bit stuck trying to get a bit of text to show for a post when the post is published within the last 72 hours.

I’ve got Pro, and have setup a condition for Datetime.

Datetime: Publish Date before last 72 hours.

I’ve tried this as a String instead of Datetime, but this didn’t work either.

If someone would be able to assist that’d be grand as I’m 99% sure I’ve seen this in 1 of your videos but I can’t remember where.

Thanks, Tom.

Hi Tom,

Can you please try Number instead of the String?

Hope it helps.
Thanks

Hi,

I’ve setup this with Number {{dc:post:publish_date}} > 24 hours - but this doesn’t work and just shows the “New” text if the post is posted after the 24th day of the month.


I haven’t used String, as mentioned, I’ve used Datetime in Pro.

This is how I have setup the Datetime one:

Just unsure where to go to find what I can and cannot put in the boxes for these Conditions - and how to make this text only show if the post has a publish date in the last 3 days (or 72 hours).

Thanks, Tom.

Hello Tom,

Use Datetime and this expression “strtotime('-72 hours')”.

If nothing is helping, provide us access to your site so that we can check your settings. Please create a secure note with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
- Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

Best Regards.

Hello @ruenel,

Unfortunately that didn’t work.

The New text doesn’t show up when I do that.

Unfortunately this is an Intranet setup and so it doesn’t have access to external networks.

But I would just like to only show the Text element after the publish date for the post is within the last 72 hours.

Thanks, Tom.

Hi Tom,

The code strtotime('-72 hours') didn’t work cause the strtotime returns the timestamp and the {{dc:post:publish_date}} returns the date in a format and that is why it didn’t match. The DateTime option can compare between to valid date and there is no such option to check the publish date as you are expecting.

Thanks

I see, can I have a way for it to just show when the post is 3 days old.

Doesn’t have to be hours, but want to be 3 days old, or in last 3 days (72 hours). I was thinking the formats wouldn’t match, can we make them match by pulling the age (in hours) of the post, and then running the strtotime.

Thanks, Tom.

Hi Tom,

Unfortunately, there is no such option available currently. I would suggest you try by creating a shortcode which will return the text, by comparing the current date and publish date. If you are not proficient, I would suggest you hire a developer who can assist you to do the customization or you can avail of our newly launched service called One, where the customization questions are answered.

Thanks

Hi,

I’ve had a further look at this and it says:

The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in now, or the current time if now is not supplied.

This means that if I do DateTime as below it should work as it’s being supplied with the Date:

{{dc:post:publish_date}} before strtotime(’-72 hours’)

I’ve also tried:

strtotime(’{{dc:post:publish_date format=“Y-m-d”}}{{dc:post:publish_time format=“H:i”}}’) is strtotime(’-72 hours’)

{{dc:post:publish_date}} after strtotime(’-72 hours’)

Is there a way I can get the age of a post in hours or minutes, then I can use strtotime(’-72 hours’) or strtotime(’-4320 minutes’)

My whole project is riding on this one thing before I can sign off and complete it, so any help would be very much appreciated - this is a project I am doing for free and so the ThemeCo One isn’t an option for me unfortunately.

Thanks, Tom.

Hi Tom,

Regretfully, as stated before that there is no such options available for what you are expecting. I still suggest you to create any custom shortcode which will return the content if the condition statisfied.
You can also go through the following article, which may help you on this.



Thanks for understanding

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.