IF Shortcodes
All WP Job Manager Emails documentation can be found in the Help tab when editing an email template.
Included with the 2.7.0 release of this plugin is also a long overdue enhancement to the standard [if]
shortcode from earlier releases. I’ve been working on these features for a while now, and finally worked out the majority of the bugs and issues to be able to include it in this release.
All of the screenshots below are from the Help tab of your site (top right corner) when editing an email template
Attributes/Modifiers
Attributes and modifiers addition to the [if]
shortcode now make it possible to combine multiple statements into one, as well as doing specific comparisons on values with numerous different comparison operators (see below).
You can negate a statement by prepending an exclamation (!
) point before the meta key, which basically means “NOT”, using comparisons or any of the other different combinations possible.
You can combine statements together to evaluate that ALL expressions are true, using the AND
operator
You can combine statements together to evaluate that ANY expressions are true, using the OR
operator
Nested IF Statements
Unfortunately due to the way that WordPress parses shortcodes, it’s not possible to nest a shortcode inside of the same shortcode, and in previous versions you could not create if statements, inside of other if statements.
With this release nested if shortcodes are now available, [if_1][if_2][if_3][if_4][if_5][if_6][if_7][if_8]
So when you need to nest an if statement inside of another one, just increase the number on the shortcode, and you’re good to go! Please note that your [else]
and closing [if]
must match the opening [if]
. For example, this would be a correct nested [if]
shortcode statement:
[if job_location] Has a job location! [if_2 job_title] [job_title] [else_2] No job title [/if_2] [else] No job location, so i'm not showing the title [/if]
IF Comparison Operators
Comparison operators can be used to customize how the [if]
shortcode will determine what to output. Previous versions did not have this feature, and would only check if there was a value.
Now you can use the new comparison operators to check if a value contains a specific string, if it equals a specific string, starts (or ends) with a string, as well as arithmetic operators such as Less Than, Greater Than, and so on!
These arithmetic operators can also be used on multiple value (and taxonomy) field types to check the number of values in that field (explain more in detail below).
Like all other documentation, you can find examples, and more details in the Help tab while editing an email template.
IF for Taxonomies and Multiple Value fields
When a field you want to use an [if]
shortcode on is a taxonomy or a multiple value field type (multiselect
, file
, etc), there is an easy way to check for a specific value, or even check all the values.
As mentioned above, when using an arithmetic operator on these types of fields, it does not check the value itself, but checks the number/amount of values.
When you need to check for a specific value, or check all the values, you can use one of the available comparison operators (such as CONTAINS
or EQUALS
), but instead of just entering one value, you can separate each value using a comma ,
(which is also known as CSV
or comma separated values).