Title: Using Switch with Today
Last modified: August 31, 2016

---

# Using Switch with Today

 *  [Besim Karadeniz](https://wordpress.org/support/users/besimk/)
 * (@besimk)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/using-switch-with-today/)
 * Hello,
 * it would be great if this works but it doesn’t:
 * [switch field=today date_format=N]
    [when value=1] [field mo_angebot] ‒ [field
   mo_preis] Euro [field mo_hinweis] [/when] [/switch]
 * Using the Today-Field with a loop in a similar matter works perfectly.
 * Besim
 * [https://wordpress.org/plugins/custom-content-shortcode/](https://wordpress.org/plugins/custom-content-shortcode/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Besim Karadeniz](https://wordpress.org/support/users/besimk/)
 * (@besimk)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/using-switch-with-today/#post-6912349)
 * Hello again,
 * I have made a workaround but it’s a bit dirty and would be better with some intentions
   from the plugin site.
 * I have a loop to get some content from post of a given category, in a specified
   year (done with a custom field named “jahr”) and a specified weeknumber (custom
   field “kalenderwoche”):
 * [loop type=post category=wochenangebot field=jahr value=today date_format=o field_2
   =kalenderwoche value_2=today date_format_2=W]
    <p>**[user]** [pass field=modified
   date_format=N] [if pass='{FIELD}’ value=1] [field monday_angebot] ‒ [field monday_preis]
   Euro [field monday_hinweis] [/if] [if pass='{FIELD}’ value=2] [field tuesday_angebot]‒[
   field tuesday_preis] Euro [field tuesday_hinweis] [/if]
 * … so on for every day of a week …
 * [/pass]
    [/loop]
 * The crux is to get the current weekdaynumber in a string. I’ve tried to get the“
   today” value in a loop which works (as a value). But using this Today-Field in
   an IF (or SWITCH) doesn’t work.
 * So my workaround gets in a PASS the modified_date of the post and formats this
   string with “N” into the ISO weekday number. When I’m scheduling this article
   with an task scheduler and reposting this post every day so this works.
 * But it would be cleaner and more secure if we could use the current date/time
   in a usable way.
 * Besim
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/using-switch-with-today/#post-6912401)
 * Hi,
 * > I’m scheduling this article with an task scheduler and reposting this post 
   > every day
 * Wow, that is quite a workaround!
 * In the newest udpate v3.3.0, I added a feature to switch by day of week:
 *     ```
       [switch day_of_week]
         [when 1]Monday[/when]
         [when 2]Tuesday[/when]
         ...
         [when 7]Sunday[/when]
       [/switch]
       ```
   
 * I hope that will simplify things for you. 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Using Switch with Today’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

## Tags

 * [date](https://wordpress.org/support/topic-tag/date/)
 * [switch](https://wordpress.org/support/topic-tag/switch/)
 * [week](https://wordpress.org/support/topic-tag/week/)

 * 2 replies
 * 2 participants
 * Last reply from: [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/using-switch-with-today/#post-6912401)
 * Status: not resolved