cristianoT
Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
| Status | Topic | Supporter | Voices | Posts | Freshness |
|---|---|---|---|---|---|
|
Map with position from custom post type in a divi site
Started by: cristianoT in: Toolset Professional Support |
|
2 | 13 | 3 years, 9 months ago | |
|
Relater post type filtered by taxonomy
Started by: cristianoT
in: Toolset Professional Support
Problem: 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. |
|
3 | 5 | 4 years, 5 months ago | |
|
Show post into a page based on page cutom field
Started by: cristianoT in: Toolset Professional Support |
|
2 | 2 | 4 years, 6 months ago |