Skip Navigation

[Résolu] Dropdown not showing complete taxonomy list & customising taxonomy dropdown

This support ticket is created Il y a 2 mois et 1 semaine. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Ce sujet contient 10 réponses, a 3 voix.

Dernière mise à jour par Minesh Il y a 1 mois et 1 semaine.

Assisté par: Minesh.

Auteur
Publications
#2761383
Screenshot 2024-09-27 at 4.25.58 PM.png
Screenshot 2024-09-27 at 4.22.58 PM.png

Hi,

Hoping you can help. I have a winery client that needs a page that partners can easily download media items attributed to wines that they sell - bottle shots, tasing notes (PDF), images taken while harvesting for a particular wine/year. It’s a very big website and we need to work with what they have already. Our solution was to have a Toolset view that looped over items in the WordPress media library and used existing taxonomies. The taxonomies we have are “Wines” and “Vintages”, which I edited to also use it on the media library. When they upload media, they will additionally select the type of wine and the vintage, if it applies. Additionally, they can also choose what type of media it is, either bottle shot, tasting notes, or production photo. I have set up a new taxonomy to class the media as such.

On the page, people should be able to select a dropdown for the type of wine, the vintage year, and the type of media, and get the appropriate assets shown to download.

I’ve managed to create the view and the filter. I had to create an additional taxonomy to tick on in order to not show the entire media library on the page before any selection had been made.

My questions:

Apologies I can’t send you a live link because I’m testing this out in a local environment.
I recorded a video to accompany my questions, as I thought it would help. Please note though, the video didn’t capture the dropdowns that I click on, so you can’t see that bit: lien caché

1) Not all the items in the taxonomy “Media Type” are showing in the dropdown despite there being images that have that media type selected. EG “Production Photo” is selected on a couple of images, yet “Production Photo” doesn’t appear in the dropdown filter. When I googled this issue, I see a team member has had this issue before, would you be able to advise what code would need to be adjusted to make sure things uploaded with taxonomies selected show as planned? https://toolset.com/forums/topic/view-dropdown-not-showing-all-taxonomies/

2) We only want to show the current year and the year before (so the most recent, and second most recent category in the taxonomy “Vintage”. The “Vintage” taxonomy has every year since 1975, nothing in the media library is categorised into any of these dates yet and we only plan to do it for the last 2 years and moving forward. As the years progress and more media with new vintage years get added, the dropdown will get longer and longer. How can I limit what appears in the dropdown? Below is what is currently in the “Search and Pagination” field, in case it helps.
[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="filtering-options">
[wpv-control-post-taxonomy taxonomy="wine" type="select" url_param="wpv-wine" default_label="Wine"]
[wpv-control-post-taxonomy taxonomy="vintages" type="select" url_param="wpv-vintages" default_label="Vintage"]
[wpv-control-post-taxonomy taxonomy="media-type" type="select" url_param="wpv-media-type" default_label="Media Type"]
[wpv-filter-reset reset_label="Clear Filters" class="clear-filters" type="button"]
</div>
[wpv-filter-spinner container="div" position="before" spinner="lien caché"][wpml-string context="wpv-views"]Refreshing list...[/wpml-string][/wpv-filter-spinner]
[/wpv-filter-controls]
[wpv-filter-end]

3) Is there a way to remove the “all” selection for “Vintages” (which is the ‘nothing selected’ option), and have it default to the most recent year?

4) We had also wanted reviews, which is a type of post with the category “Reviews” to show within the mix of this media filter. These also have the wine and vintage taxonomy applied. However, I just couldn’t get it to work, so the next best solution is to have a separate section on the page showing the reviews with a filter for “wine” and “vintage” for people to select. Is it possible to have the filter from the media section also control the reviews section? So, one filter to show media and reviews with the same control so the user doesn’t have to select both?

Thank you for your help,
Jo

#2762827

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I will have to review the settings you have and for that I will require staging site.

Can you please try to setup the staging site and then once I see the issue I will be able to guide you in the right direction with any possible solution or workaround, if any available.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test/staging site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2776403

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

When I try to access the link you shared: lien caché

I see its shows 404 error and the site is not accessible.

Can you please send me working admin access details.

I have set the next reply to private which means only you and I have access to it.

#2777281

I think this is a little hard to coordinate because we're in different timezones and you can't log into the website unless my local site is online. It looks like the live link must time out because I had it open all day.

I think I'm 2.5 hours ahead of you. I will check the site is online each day next week at 11:30am and 2pm (9am and 11:30am your time). Hopefully you will be able to log into it when you're able to get back to it.

#2777367

Mateus Getulio
Supporter

Les langues: Anglais (English )

Fuseau horaire: America/Sao_Paulo (GMT-03:00)

Hello there,

This is a quick follow up to let you know Minesh is not available today but he'll be back shortly and reply to you as soon as possible.

In the meantime, if it'd be possible to perhaps set up the staging site in a different enviroment that's open for access or replicate it to a sandbox containing a fresh copy of WordPress and Toolset: lien caché

You can reproduce the issue in there so we can analyze in a fresh install.

Thank you for your understanding.
Mateus

#2777839

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Are you able to setup the things on sandbox site shared by Mateus?

#2778123

Hi Minesh,

Thanks for following up, and thank you Mateus for posting the sandbox site.

To make things easier moving forward, and also because I need my team to also be able to work on this site shortly, I've copied the site into a live environment. I have created you a user, could you please allow the posting of a private reply so I can give you access?

#2778124

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

*** Please make a FULL BACKUP of your database and website.***
I have set the next reply to private which means only you and I have access to it.

#2778524

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

I've added the following filter that will show only last two years term with the vintages taxonomy filter dropdown and I've added the following code to "Custom Code" section offered by Toolset:
=> lien caché

add_filter('wpv_filter_taxonomy_frontend_search_get_terms_args','func_include_last_two_years_terms',10,3);
function func_include_last_two_years_terms( $args, $tax, $view_id ){

if ( $view_id == 47454  && $tax == 'vintages' ){
  
   $current_year = date("Y");
   $allowed_term_slug[] = $current_year;
   $allowed_term_slug[] = $current_year-1;
  
   $args['slug'] = $allowed_term_slug; 
}
return $args;
}

More info:
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_frontend_search_get_terms_args

Can you please confirm it works as expected:
- lien caché

#2778735

Hi Minesh,

Thank you. Yes it only shows the two most recent vintage years in the dropdown. Next year when 2025 is added, I assume it will show 2025 and 2024 only? The thing that is not working as expected is the results still show all the media for all the years. If we can get the view to default to the most recent vintage, and remove the 'clear' button, that might resolve that.

#2778743

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Ok - if you want to prefilter the view results as well then I've adjusted the code added to "Custom Code" section as given under:
=> lien caché

add_filter( 'wpv_filter_query', 'func_prefilter_vintage_taxonomy', 99, 3 );
function func_prefilter_vintage_taxonomy( $query_args, $view_settings, $view_id ) {
 
   $display_view_ids = array(47454);
      
    if (in_array($view_id,$display_view_ids) and ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )){
      
      $current_year = date("Y");
   	  $allowed_term_slug[] = $current_year;
      $allowed_term_slug[] = $current_year-1;

      
      $query_args['tax_query'][] = array(
            'taxonomy' => 'vintages', // taxonomy name
            'field' => 'slug',
            'terms' => $allowed_term_slug, 
            'operator' => 'IN'
        );
       
         
    }
    return $query_args;
}

Can you please confirm it works as expected:
- lien caché