Problem:
I need to display both the date of the post and the date minus one year of the post, within the same view.
Solution:
1. Add following code in your theme’s functions.php file:
add_shortcode('past_year_date', 'get_past_year_date_fun'); function get_past_year_date_fun( $atts ) { // Attributes extract(shortcode_atts( array( 'date' => '', 'format' => 'M d, Y' ), $atts )); $past_date = strtotime("$date -1 year"); $date = date($format, $past_date); return $date; }
2. Then use following shortcode for display past year date:
Current Date: [wpv-post-date] Past Year Date: [past_year_date date="[wpv-post-date]" format="M d, Y"]
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | - |
- | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | - |
Supporter timezone: Asia/Karachi (GMT+05:00)
This topic contains 5 replies, has 2 voices.
Last updated by 7 years, 2 months ago.
Assisted by: Noman.