Skip Navigation

[Resolved] I need archive to get filtered by latest value of ancestor

This support ticket is created 6 years, 9 months ago. 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 8 replies, has 2 voices.

Last updated by Shane 6 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#549939

I am trying to:

I have post hierarchy Events->session->presentations. In presentations "archive view" I put ancestor filters events>session.

I put default_value of session filters as "--select--". Note that I haven't put a default_value for Events.

When I open the archive url the page displays all the presentations. I want to filter the presentations by latest Event in select box by default in presentation archives.

Please suggest how can I achieve this.

I visited this URL:

I expected to see:

Instead, I got:

#549993

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Khurram,

Thank you for contacting our support forum.

Would you mind providing me with admin access to the this archive so that I can have a look at how things are setup ?

Maybe from looking at what you already have I will be able to best advise on the way forward.

The private fields will be enabled for your next response.

Thanks,
Shane

#550162

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Would be possible to share the credentials for this demo site so I can have a look here ?

Thanks,
Shane

#550389

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Khurram,

I understand what you are saying now. Actually this would be possible to do with a custom hook, however this will disable the frontend filters and allow them to only display the results for the latest parent and all the other filters will re-adjust for that. You won't be able to select any other parent except the one that has been pre-filtered for since the hierarchy for filters means that the hook will always take priority.

So essentially its not possible without some trade off.

Thanks,
Shane

#550536

I think this should how the standard method work.
I got another idea for workaround. Is it possible to not display result first time the archive page is opened. So that a user will use filters to fetch the results.

#551218

Dear Shane,

Please point me to custom hook you discussed above. I would try to experiment the possibilities of filtering views as well.

Thanks,

#551487

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Khurram,

Sorry for the delayed response but the hook that you should be using is the one below.
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

If there is anything that you are not clear on please let me know and i will be more than happy to assist .

Thanks,
Shane

#551696

Hi Shane,

For testing purpose I include following filter in my functions.php but it didn't worked. I understood that $query_args contains WP_Query args and I applied same args type.

add_filter( 'wpv_filter_query', 'set_args_for_event' ,99,3);
function set_args_for_event( $query_args ) {

	$query_args[] = array('meta_query' => array(array('key' => '_wpcf_belongs_event_id', 'value' => 11957)));
	return $query_args;
}
#552136

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Khurram,

I found a better hook that you can use, one specifically for archive.
hidden link

For this you may need to write a condition to check the archive if its the correct one so that the code does not apply to all your other archives.

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.