Support

Home Forums Event Espresso Premium Search Function help

Search Function help

Posted: March 19, 2018 at 3:09 pm

Viewing 6 reply threads


James Cox

March 19, 2018 at 3:09 pm

Hi there

I need to find a way to get the quick search function on the homepage of this website phoenixhsc.co.uk – just underneath the menu.

I have tried working with WPtypes/WPViews and WPSearch but cant seem to get it configured correctly.

Is there a way (an easyish) via a plugin anyone knows of that could help me achieve it or can point me in the direction of some code so I can do it?

Much appreciated.
James


James Cox

March 19, 2018 at 3:13 pm

In the link above – accreditation being parent category and course being child category


Josh

  • Support Staff

March 19, 2018 at 3:45 pm

Hi James,

If those are all event categories then you could use the WordPress navigation menu manager and set up a menu item for each category, no coding required.

If you want to build something with PHP, one WordPress function that you can use is wp_dropdown_categories(). With wp_dropdown_categories() you set the taxonomy, so you’ll set:
'taxonomy' => 'espresso_event_categories'


James Cox

March 19, 2018 at 4:03 pm

Thanks Josh!

For the PHP can you point me in the direction please for implementation?

Also With the first option can I separate it out into 2 drop downs?

Thanks for your help


Josh

  • Support Staff

March 19, 2018 at 4:25 pm

If you want to build something with PHP, one WordPress function that you can use is wp_dropdown_categories(). This will output a dropdown.

If you want to output a list, then you can use get_terms() and follow this example:
https://developer.wordpress.org/reference/functions/get_terms/#comment-288

With either of the above functions you set the taxonomy, so you’ll set:
‘taxonomy’ => ‘espresso_event_categories’

Also With the first option can I separate it out into 2 drop downs?

Can you clarify? What’s the first option, and what are the two items you’re looking to separate it out into?


James Cox

March 19, 2018 at 4:31 pm

phoenixhsc.co.uk – the quick search underneath the menu – accreditation and courses section – I need search functionality like that. So parent category dropdown then show relevant child categories in the second.


Josh

  • Support Staff

March 19, 2018 at 4:37 pm

You should be able to use get_terms() for both of those. You can set hierarchical to true when you want to include child categories, and you can also use child_of and parent arguments.
See also:
https://developer.wordpress.org/reference/classes/wp_term_query/__construct/

Viewing 6 reply threads

The support post ‘Search Function help’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso