Problem: I would like to create an accordion-style View. I would like to output the name of a day, starting with a date passed in by a custom field and continuing for several days. I am using Visual Composer.
Solution: Switch to Visual Composer "Classic Mode". Use Views to generate the shortcode structure required for your accordion tabs and panels by looping over posts:
[wpv-layout-start] [wpv-items-found] [vc_tta_accordion] <!-- wpv-loop-start --> <wpv-loop> [vc_tta_section title="[wpv-post-title]" tab_id="wpv-vc-tab-[wpv-post-id]"][vc_column_text][wpv-post-body][/vc_column_text][/vc_tta_section] </wpv-loop> <!-- wpv-loop-end --> [/vc_tta_accordion] [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
Add the following custom shortcode definition to functions.php:
add_shortcode( 'displaydate', 'displaydate_func'); function displaydate_func($atts){ $increment = $atts['increment']; $start = $atts['start']; $m = date("m", $start); $d = date("d", $start); $Y = date("Y", $start); $day = mktime(0, 0, 0, $m, $d + $increment, $Y); return date('l', $day); }
Output the name of a day with the shortcode:
[displaydate increment="3" start="[types field='startdate' output='raw'][/types]"]
Replace "3" with the number of days in the future, and replace "startdate" with the slug of your custom field. Add the "id" attribute if you want to specify a different post, other than the current post or current post in the loop.
Relevant Documentation:
http://php.net/manual/en/function.date.php
https://toolset.com/documentation/user-guides/date-filters/
https://toolset.com/documentation/user-guides/filtering-views-query-by-date/
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.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Dieses Thema enthält 5 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von vor 7 Jahren, 4 Monaten.
Assistiert von: Christian Cox.