Skip Navigation

[Resolved] Split: Alphabetical view – prefilter taxonomy view results

This thread is resolved. Here is a description of the problem and solution.

Problem:
Split: Alphabetical view - prefilter taxonomy view results

Solution:
To prefilter the view result before it displays you need to use the view's filter hook wpv_filter_taxonomy_query

You can find the proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/split-alphabetical-view-conditional-check-of-tags/#post-1241642

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_query

This support ticket is created 5 years, 7 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.

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)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by ThorstenS967 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1241621

Thanks a lot.
Now I want to display the tags only, if you click on one of the letters and not if you click on the page and haven't clicked on one of the letters yet. I tried this solution: https://toolset.com/forums/topic/if-wpv-post-param-has-a-specific-var-then/
and replaced it like

[wpv-conditional if="( '[wpv-search-term param="term-filter"]' ne '' )"]
<div>[wpv-taxonomy-link]</div>
[/wpv-conditional]

but this doesn't work.

#1241624

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - can you tell me what exactly you want to display conditionally?

Do you mean that you want to display "ALL" tags once you click to a specific character?

#1241627

If you click on hidden link it lists all tags under the alphabetical letters. What I want is, taht if you click on hidden link, it only shows the alphabetical letters without the tags and if you click on the letters, it shows the corressponding tags (that is already correct right now). So the tags (for the corressponding alphabetical letters) should only appear, if you click on the letter(s).

#1241642

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - for that I've adjusted the code added to custom code section a little bit as given under:
=> hidden link

add_filter( 'wpv_filter_taxonomy_query', 'func_filter_taxview_by_char', 99, 4 );
function func_filter_taxview_by_char($tax_query_settings, $view_settings, $view_id){
      
    if($view_id == 1591 and isset($_REQUEST['terms-filter']) and $_REQUEST['terms-filter']!=""){
 
      
      $res =  get_terms( 'post_tag', 'term_char='.$_GET['terms-filter'] );
 
      $ids = array();
      foreach($res as $k=>$v):
      	$ids[] = $v->term_id;
      endforeach;
      
    $tax_query_settings['include'] =  	join(",",$ids);
   }else if($view_id == 1591 and !isset($_REQUEST['terms-filter'])){
     
       $tax_query_settings['name__like'] =  "00000";      
   } 
        
    return $tax_query_settings;
}

I can see now no results displayed until you select the specific character:
=> hidden link

#1241697

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you confirm the solution I shared works for you.

#1241762

Sorry, I had a private appointment a view hours. It's almost perfect, but now it shows "no items found". If this would also disappear, the solution would greatly fit my needs.

#1241778

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok doen. I've removed that message.

#1241793

My issue is resolved now. Thank you!