The issue here is that the user wanted to prefilter their post reference field options. In this case they wanted to retrieve specific posts from a particular taxonomy.
Solution:
This can be done by using the hook below.
/**
* Limit the posts offered in the Post Reference dropdown to those with a particular term assigned
*
* Edit
* 1. the slug of the post type in the if statement as required ('review' in this example) as well as the custom field slug 'wpcf-my-reference'
* 2. the slug of the taxonomy ('colour' in this example)
* 3. the slug(s) of the terms that should match ('red' in this example)
*/
function ts_filter_related_post_selector( $query )
{
if ( defined('DOING_AJAX') && $_REQUEST['action'] === 'types_post_reference_field' && $_REQUEST['field_slug'] === 'wpcf-my-reference' && $query->query['post_type'][0] === 'review' ) { // edit
$taxquery = array(
array(
'taxonomy' => 'colour', // edit
'field' => 'slug',
'terms' => array('red'), // edit
'operator' => 'IN'
)
);
$query->set('tax_query', $taxquery);
}
}
add_action('pre_get_posts', 'ts_filter_related_post_selector');
Add this code to the Toolset Custom code settings at Toolset -> Settings -> Custom Code and activate it.
This will produce links to the terms' archives, separated by a comma(,).
You can also iterate through the array of terms with the wpv-post-taxonomy-iterator and produce the markup that you need with the wpv-taxonomy-* shortcodes:
The issue here is that the customer wants to always show values that will produce a No Results Found on their view filters rather than having only values that will produce a result.
Solution:
On your view you should be able to see the custom search settings section.
When you choose the setting "Let me choose individual settings manually", under "Which options to display in the form inputs" choose "Always show all values for inputs"