Skip Navigation

Views Conditionals populated with Types Fields (not from current post) will fall back to the current post’s data

Open

Reported for: Toolset Views 2.6.4.2

Topic Tags: Views plugin

Symptoms

When you compare data of Types Fields in a Views Conditional and call fields that are not from the current post (parent page, parent post, parent media, parent post type), the comparison falls back to the current post’s fields data.

Example:

[wpv-conditional if="( $(wpcf-checkbox).id(page) eq '1' )"]Yes, it's 1[/wpv-conditional]

This conditional will not “listen” to the parent page field but to the current page field.

Workaround

This can be resolved by not using Types Fields as a source but Views Shortcodes instead.

The following example does exactly the same as in the issue’s example above:

[wpv-conditional if="( '[types field='checkbox' output='raw' item='$parent'][/types}}' eq '1' )"]Yes, it's 1[/wpv-conditional]

Note, this is valid for all kinds of related data (whether WordPress or Toolset relationships).

Leave
a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>