Checking Types Fields

You can test your custom fields defined with the Types plugin for meeting specific criteria.

Testing Types fields with the GUI

To check a Types field with the GUI, select Types Fields as the Data origin. From the second dropdown select the field you want to use in your condition and from the third dropdown select the source of the field.

Types field condition
Types field condition

Testing Types fields with the wpv-conditional shortcode

To test a Types field with the wpv-conditional shortcode remember to add the wpcf– prefix to the field name. The Types plugin appends wpcf– to all field names.

Testing Types fields with the wpv-conditional shortcode
[wpv-conditional if="($(wpcf-price) lt '50' )"]Special price! Join now! [/wpv-conditional]

In case that you want to compare a field from a parent source, the syntax should be similar to the following:

Testing Types fields from parent source
[wpv-conditional if="( $(wpcf-price).id(product) lt '50' )"]The parent product is in special price! Join now! [/wpv-conditional]

 

Checking Custom Fields

In your condition you can also test custom fields created outside the Types plugin:

  • fields added directly using the WordPress GUI
  • fields provided by third party plugins or themes

This is an example custom field created using the WordPress GUI:

f

Testing custom fields with the GUI

All custom fields available in your WordPress site will be listed automatically if you choose Custom Fields for the Data origin in the Conditional output GUI:

Condition for custom field
Condition for custom field

Testing custom fields with the wpv-conditional shortcode

Testing custom fields with the wpv-conditional shortcode
[wpv-conditional if="( $(featured) eq '1' )"] This post is featured. [/wpv-conditional]

In case that you want to compare a custom field coming from a parent post types, the syntax should be similar to:

Testing custom fields from parent source
[wpv-conditional if="( $(featured).id(post) eq '1' )"]The parent post is featured.[/wpv-conditional]


Checking radio fields values

Supposing you have the gender field defined as a radio field with the Types plugin:

you can test for a consultant gender using the following code:

Test consultant gender
Consultant about [wpv-conditional if="( $(wpcf-consultant-gender) eq '1' )"]herself[/wpv-conditional] 
[wpv-conditional if="( $(wpcf-consultant-gender) eq '2' )"]himself[/wpv-conditional]


Using fields together with date filters

In your conditions you can compare your date fields with VIews built-in date and time functions.

If you have your date field defined with the Types plugin, you can check if the current value in that field is the same as today’s or is in the future comparing it with the TODAY() function.

Checking if a date is today

using the GUI

Checking if a date is today
Checking if a date is today

using the wpv-conditional shortcode

Checking if a date is today
[wpv-conditional if="( $(wpcf-free-consultations-due-date) eq 'TODAY()' )"]
Today is the last chance for free consultations. Contact us for more details.[/wpv-conditional]

Checking if a date has already passed

Checking if a date has already passed
[wpv-conditional if="( $(wpcf-free-consultations-due-date) lt 'TODAY()' )"]
We are sorry but  this offer has expired.[/wpv-conditional]


Using fields with math operators

You can use math operators : +,-,*,/ in your conditions.

Math operators
[wpv-conditional if="( $(wpcf-budget)*2 lt '400' )"] Special offer for couples [/wpv-conditional]

[wpv-conditional if="( ($(wpcf-consultant-price-per-hour) -  $(wpcf-discount) ) gt 200  )" ] 
For VIPs only [/wpv-conditional]

Math operators can be used on both sides of the comparison operator:

Math operators can be used on both sides of the comparison operator
[wpv-conditional if="( ($(xyz-factor) + 2) gt $(wpcf-employee-age) - ($(wpcf-work-experience))" ] 
The employee is protected [/wpv-conditional]


Other examples