Skip Navigation

[Resolved] Using Fields & Text and conditional logic for post meta date published /modified

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Waqar 1 year, 4 months ago.

Assisted by: Waqar.

Author
Posts
#2624835

Tell us what you are trying to do? I'm trying to replace my theme's default post meta with conditional logic to display:
BY AUTHOR (if published, display month/day/year) or (if modified, display month/day/year timestamp)
I don't want to display both published and modified dates, though.

I'm sure this is possible somewhere, maybe using fields & text, I just haven't tracked down the right docs to support this. Any and all help is tremendously appreciated, thank you!

#2624897

Hi,

Thank you for contacting us and I'd be happy to assist.

The shortcode for the post author link is:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-author )


[wpv-post-author format="link"]

And the shortcode for the post published date is:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-date )


[wpv-post-date]

And the shortcode for the post modified date is:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-date )


[wpv-post-date type='modified']

Combined them togather in a single line, with conditional statements, will look like this:
( ref: https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/ )


By [wpv-post-author format="link"]

[wpv-conditional if="( '[wpv-post-date]' eq '[wpv-post-date type='modified']' )"]
published on [wpv-post-date]
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-date]' ne '[wpv-post-date type='modified']' )"]
modified on [wpv-post-date type='modified']
[/wpv-conditional]

The above code will show the post author link, followed by the post published date if the post published date and the post modified dates are the same. And will show the post modified date, if they are different.

I hope this helps and please let me know if you need further assistance.

regards,
Waqar

#2625079

Hi Waqar,

Thank you for the reply! I added this to fields and text, but this only results in "By (author)"- not linked to archive. And the dates don't display at all, but I noticed that I don't have the conditional "if" icon displaying in fields and text or in classic editor. The only conditional thing I can find is the conditional gutenberg block. Would this be a problem? For context, I'm using Astra theme and only have Toolset Blocks and Types installed. I also registered "wpv-post-date" as a function inside conditional evaluations under my "Front-end Content" settings, since I didn't see it registered automatically, but that didn't seem to make a difference.

#2625333

It is strange that the shortcodes are not working for you.

To troubleshoot this, I'll need to see how and where exactly you're trying to use them, in the admin area.

Can you please share temporary admin login details, along with the link to the page where you've tried this code?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

#2625767

Hi Waqar,

Thanks for the reply and offer and sorry for the delay in replying. I'm going to put a pin in this for now, because it's not a terribly important issue right now and I've got some other problems I'm solving. I had hoped it was just a simple error on my end that I could easily fix (and maybe it is), but it's not super important right now and I'm still working on getting my website up and running.

Thank you though for your time and attention and help, I do appreciate it and may revisit this in the future.

#2625967

You're very welcome and please take your time.

This ticket will stay open for a couple of weeks. And, even if you need to revisit this, after the ticket has closed, you can start a new one and just include this ticket's link in that, for the context.