In the examples that follow we will use a custom taxonomy called “Foreign language” defined with the Types plugin. This taxonomy is assigned to the Consultant custom post type:

Checking if a post has at least one term assigned

Use the wpv-post-taxonomy shortcode to test if a post has at least one term assigned.

Checking if a post has at least one term assigned
[wpv-conditional if="('[wpv-post-taxonomy type='foreign-language' format='slug' ]' ne '' )"]
<strong>Foreign languages: </strong>[wpv-post-taxonomy type="foreign-language"]
[/wpv-conditional]

The above code will output the following block (marked with the red border) if a consultant speaks at least one foreign language:


Checking if a post has a specific term assigned

In our example, we want to emphasize the fact that a consultant speaks Chinese. We want to display the relevant message only if a post has the ‘Chinese’ term assigned.

To achieve this do the following:

Conditional output based on taxonomy
Conditional output based on taxonomy

  1. Within View user interface select the code that you want to be conditionally displayed.
  2. Click the conditional output button
  3. In Field section select the taxonomy and its source.
  4. In Comparison dropdown select if the taxonomy should or should not include the Value. Keep in mind that in the Value filed you should enter the slug of taxonomy term and not the taxonomy term itself.
  5. Insert shortcode

The shortcode that is inserted will look something like this:

Conditional output based on taxonomy
[wpv-conditional if="( CONTAINS(#(foreign-language),'chinese') )"]
<p>This consultant speaks Chinese!</p>
[/wpv-conditional]

Checking for a specific term in a View listing all terms

If your View is listing all terms of a specific taxonomy (see the picture below), you can use wpv-taxonomy-slug or wpv-taxonomy-title shortcodes to test if a term currently displayed matches the desired value.

image01

Checking for a specific term in a View listing all terms
[wpv-conditional if="( '[wpv-taxonomy-slug]' eq 'chinese' )"] 
<strong>new!</strong> [/wpv-conditional]

The above code will output the following:


Other examples