Skip Navigation

[Resolved] Need help with setting up proper filtered view display on the front

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Waqar 10 months ago.

Assisted by: Waqar.

Author
Posts
#2684800
att2.jpg
att1.jpg

Tell us what you are trying to do?
- I need my filtering to work on the page properly. On the "About us" page Our Fertility Team view by default to load Expert Doctors. (see att1.jpg) and on the Our Wider Team to load Midwives (see att2)
Is there any documentation that you are following?
- See attached screenshots.
Is there a similar example that we can see?
- I couldn't find anything similar in your database to solve my issue.
What is the link to your site? hidden link

#2684882

Hi,

Thank you for contacting us and I'd be happy to assist.

To troubleshoot this, I'll need to see how these pages and filters are set up in the admin area.

Can you please share temporary admin login details, in reply to this message?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2685111

Any progress with solving this issue?

#2685218

Thank you for sharing the access details.

To set a default taxonomy filtering, when the page loads and no other taxonomy term has been selected, you can use the 'wpv_filter_query' filter:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

For example, the view 'Team Top Members' with ID "155" is used on the 'About Us' page. To set a default taxonomy filter for taxonomy 'top-position' with the term slug 'expert-doctors', the code will look like this:


add_filter( 'wpv_filter_query', 'filter_include_cat_fn_155', 1000 , 3 );
function filter_include_cat_fn_155( $query_args, $view_settings ) {

	if ( (isset($view_settings['view_id'])) && ($view_settings['view_id'] == 155) ) {
		if(empty($query_args['tax_query']))
		{
			$query_args['tax_query'][0]['taxonomy'] = 'top-position';
			$query_args['tax_query'][0]['field'] = 'slug';
			$query_args['tax_query'][0]['terms'][0] = 'expert-doctors';
			$query_args['tax_query'][0]['operator'] = 'IN';
			$query_args['tax_query'][0]['include_children'] = '';
			$query_args['tax_query']['relation'] = 'AND';
		}
	}

	return $query_args;
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

Similarly, you can create another code snippet for any other views that you'd like to set a default taxonomy filter. For more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

#2685598

Hi Wakar,

Thank you for the help. I did the top members part and it shows correctly with the 2 tabs visible, however, when I added the second one with the bottom members the tabs are not visible except the priority one. When I give an array to add all and make the midwives first it is not showing the 'administrators' and underneath shows all members:

// filter bottom-members by priority category shows only 'midwives ' tab above the members

add_filter( 'wpv_filter_query', 'filter_include_cat_fn_159', 1000 , 3 );
function filter_include_cat_fn_159 ( $query_args, $view_settings ) {

if ( (isset($view_settings['view_id'])) && ($view_settings['view_id'] == 159) ) {
if(empty($query_args['tax_query']))
{
$query_args['tax_query'][0]['taxonomy'] = 'bottom-position';
$query_args['tax_query'][0]['field'] = 'slug';
$query_args['tax_query'][0]['terms'][0] = 'midwives';
$query_args['tax_query'][0]['operator'] = 'IN';
$query_args['tax_query'][0]['include_children'] = '';
$query_args['tax_query']['relation'] = 'AND';
}
}

return $query_args;
}

// adding filter bottom-members by priority category with array starting with 'midwives ' from the tabs above the 'administration is not displayed

add_filter( 'wpv_filter_query', 'filter_include_cat_fn_159', 1000 , 3 );

function filter_include_cat_fn_159( $query_args, $view_settings ) {
if ( isset( $view_settings['view_id'] ) && $view_settings['view_id'] == 159 ) {
// Ensure we're modifying the correct query arguments
if ( empty( $query_args['tax_query'] ) ) {
// If tax_query is empty, initialize it
$query_args['tax_query'][0]['taxonomy'] = 'bottom-position';
$query_args['tax_query'][0]['field'] = 'slug';
$query_args['tax_query'][0]['terms'] = array( 'midwives', 'nurses', 'administration', 'accounting', 'services' );
$query_args['tax_query'][0]['operator'] = 'IN';
$query_args['tax_query'][0]['include_children'] = '';
$query_args['tax_query']['relation'] = 'AND';
}
}
return $query_args;
}

Why the bottom members tabs cannot be shown like the top members but only 'midwives' active and when I add array the 'administration' is missing? I various tried combinations with selecting by IDs, Types, Names and no success.

Thank you in advance for your assistance.

Regards,
Vessy

#2685702
screenshot-view-settings.png

Hi Vessy,

Thank you for this update.

I apologize for missing out on this detail, earlier.

In the view 'Team Top Members', I had set the search settings to 'Always show all values for inputs', as shown in the attached screenshot.

By default, the view's search form only shows those options in the search fields, which can produce some results. And because of the custom filtering that our code is applying, the other options were getting removed.

I've made the same change to the other view's search settings (Team Bottom Members) and now all options are showing under the 'Our Wider Team' section too.

regards,
Waqar

#2685727

Hi Waqar,

Thank you for helping me set up this right.
Your assistance is much appreciated.
I will keep this for my future reference.

Best regards,
Charitos