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.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
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)
Ce sujet contient 5 réponses, a 2 voix.
Dernière mise à jour par Il y a 7 années et 3 mois.
Assisté par: Noman.