Tell us what you are trying to do?
I need to show a dropdown menu in the archive of members CPT with the countries (taxonomy) that belong to a category (another taxonomy)
I have an archive for a custom post type called Members
That CPT have 2 taxonomies: ITF Member Categories and Countries
I built the layout with Archive block editor and activated the option: Show only filter options that would produce results
and added a Countries as a Search field with Type of control: Select Dropdown
It works but, when I dropdown the menu I see all of the countries.
When I select any country and then I dropdown the menu again, then I see only the countries that belong to that Category
Is there any documentation that you are following?
no
Is there a similar example that we can see?
see the images I upload, I don't know if this is a bug or I'm a bug...
What is the link to your site?
hidden link
Hi,
Thank you for contacting us and I'd be happy to assist.
To troubleshoot this, I'll need to see exactly how this archive and its search filter 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 it is recommended to make a complete backup copy, before sharing the access details.
regards,
Waqar
Thank you for sharing these details, but, I keep getting the message that the username or password is incorrect.
Can you please check the username and password again?
Note: Your next reply will be private.
try it now (it's a multisite and I forgot to set your user as a super administator)
Thank you for waiting as we had a busy forum queue around the weekend.
I'm afraid I'm still getting the "The username or password you entered is incorrect" message while trying to log in to the admin area.
Can you please check the username and password again?
( just to be safe, you can use my test email address 'test@waqar.xyz' for this temporary user account so that I can reset the password if needed )
Note: I've set your next reply as private.
I changed your account email and sent a reset password link.
thank you!
Thank you for updating the email and I was able to access the website's admin area.
The challenge here is that the "ITF Member Categories" and the "Countries" taxonomy terms have no connection between them. This is why there is no way to limit the options that are shown in the "Countries" search dropdown, on the "ITF Member Categories" term archive pages.
When the search has been performed, the search form's options are updated and are limited to the options which can produce search results, and only the countries from the current "ITF Member Categories" terms are shown.
A workaround, in this case, can be to include some script in the archive's "Custom JS" section, which triggers a change event to the country search field, when the page loads:
( screenshot: hidden link )
jQuery( document ).ready(function() {
jQuery('select[name="wpv-itfmember_country"]').trigger('change');
});
I hope this helps and please let me know if you need any further assistance around this.
Waqar your solution was really good! Thank you!
I'm wondering if the structure I've used is ok.
I'm not programmer. And I think that maybe the "system" I designed is not good enough.
Do you think there is a better post tyepe + taxonomy combination to create this kind page with filter (Continent/Country)?
Thank you again!
(I'm impressed with your speed to find a solution!)
Thanks for the update and glad I could help.
I feel your current setup of using two taxonomies for "Continents" and "Countries" is the most efficient one because, from a performance point of view, filtering by taxonomy is better optimized than filtering by custom fields or post-relationships.
As long as the correct continent and its country term are assigned to each member post, you'll be fine.
One alternative could've been using separate CPTs for "Continents" and "Countries" and then linking all three CPTs through two one-to-many post-relationships ( Continents -> Countries, and Countries -> Members ). However, for the reason mentioned above, I would prefer your existing taxonomy approach over this 'CPTs + post-relationships' approach.
I was wondering if I could use countries as sub categories of continent. Something like this:
Africa
-- Algeria
-- Burundi
-- Djibouti
-- ...
-- Zimbabwe
Asia
-- Afghanistan
-- Azerbaijan
-- ...
-- Vietnam
and so on.
What do you think about this approach?
Thank you
Using a single hierarchal taxonomy for the continents and countries can also work.
However, you'll lose the ability to perform the search by two separate fields for continents and countries. There will be a single taxonomy field to select continents and countries.
My issue is resolved now. Thank you!