Skip Navigation

[Gelöst] I need to set visible an hour field only if is set different of 00:00

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem: Display the time for a custom date field only if the user selects a time.

Solution: Use separate custom inputs for hour and minutes, and include an option for "nothing selected" in each of these. Use conditional logic in your View to determine if values have been selected for these inputs, and display the time based on those selections.

Relevant Documentation:

This support ticket is created vor 6 Jahre, 1 Monat. There's a good chance that you are reading advice that it now obsolete.

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
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)

This topic contains 4 Antworten, has 2 Stimmen.

Last updated by aldoR vor 6 Jahre, 1 Monat.

Assigned support staff: Christian Cox.


I am trying to: I need to show the hour of an article only if the hour in the date field is set to a specicif hour (ex. 08:45) and hide the hour in the frontend when the hour is not set (ex. 00:00)

So when an article have only a date, I want to show this date in frontend, when an article have the date and the hour, I want to show both

I visited this URL:

I expected to see:

Instead, I got:


Hello, I'd like to make sure I understand you correctly. You said you want to show the hour on the front end "only if the hour in the date field is set to a specific hour." You also said you want to show the hour on the front end "if is set different of 00:00". These are different rules, and the difference is important, so I need some clarification.

If you look at the date and time inputs, 00:00 is a specific hour, and it is not possible to select an option without a specific hour or a specific minute. In other words, a date with time field will always have a specific hour and will always have a specific minute, even if that is "00".

With that in mind, do you want to test if the hour or minute is something other than 00, or do you want to test if the user has not selected something for hour or minute?

Schermata 2017-02-08 alle 09.43.53.png
Schermata 2017-02-08 alle 09.44.12.png

Ok I'm thinking for a workaround.
If I create two separate fields, the first for the date only (I see it's possible to set this) and on other two select field one with hour, one with minutes.

So In view I've added this code: [types field="date" style="text" format="j F Y"][/types] - [types field="hour"][/types]:[types field="minutes"][/types]

In frontend the output correctly shows the minutes only in articles with this fields set, but I see still the " - " and ":" carachters between the hour e minutes fields.

Now I need only a way to put the " - " and ":" in types field hour or minutes for show only when necessary

I hope you understand my needs, If you look this page hidden link
you see the output page, you see the " - " and ":" carachters also in the articles wit non hour, minutes settings.

thanks in advance, Aldo


Okay, you'll need to use conditional output that tests the value of hour and minutes. If hour AND minutes do not equal an empty string, you will show the content. Here's an example of a conditional that tests custom fields "hour" and "minutes":

[types field="date" style="text" format="j F Y"][/types]
[wpv-conditional if="( $(wpcf-hour) ne '' ) AND ( $(wpcf-minutes) ne '' )"]
 - [types field='hours'][/types]:[types field='minutes'][/types]

Some more information on conditional output here:


GREAT!!! now the output in frontend works wery well..
tnx again Christian