Skip Navigation

[Cerrado] Parametric search and filtering by related content

This support ticket is created hace 9 años, 5 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

Etiquetado: 

This topic contains 3 respuestas, has 2 mensajes.

Last updated by Adriano hace 9 años, 5 meses.

Assisted by: Adriano.

Autor
Mensajes
#227522

Hi
is it possible to create a view with parametric search and filter it by related custom type?

I have 3 types:
Courses
Trainers
References as my help object to allow many to many relationships between courses and trainers

I would like to create a view to display courses and filter them by related Trainers, is it possible?

Regards,
Michael

#227571

Dear Michael,

This filter is not in our list of available filters. But as workaround you can create this manually:

1) Inser the Filter code manually in right section. The value must be the right post type slug name:

<select name="post_type">
<option value="Courses">Courses</option>
<option value="Trainers">Courses</option>
</select>

2) Use wpv_filter_query to extend the filter of this view:

add_filter('wpv_filter_query', 'filter_post_type', 10, 2);
function filter_post_type($query, $settings) {
    if($settings['view_id'] = 123)
    {
    	if(isset($_GET['post_type'])){
	    	$query['post_type'] = $_GET['post_type'];
	        return $query;
    	}
    }
}

You must replace 123 with the ID of the view. It will return only posts with the same post type of the URL parameter value "post_type": hidden link

#227876

Hi Adriano, I'm not sure if I explained it right. I would like to create a view of courses and filter it by related trainers, so the filter option should be:

Filter:
<option>Trainer 1</option>
<option>Trainer 2</option>
<option>Trainer 3</option>

View:
Course 1
Course 2
Course 3
Course 4
....

Then if I choose in filter 'Trainer 2' it will show me only the courses where this trainer is an author of the course. Is it possible?

Is it possible to generate the trainers list in filter(options) dynamically, so if the trainer profile is deleted it will be no more available in filter as option to select?

Regards,
Michael

#228013

Dear Michael,

Right, go to your view, then add the "Post Relationship - Post is a child of:" filter. You must choose the option "Post with ID set by the URL parameter". The thing you need to do now is to send the correct ID of the right parent in the URL argument.

El debate ‘[Cerrado] Parametric search and filtering by related content’ está cerrado y no admite más respuestas.