Jetpack Portfolio: How to trigger filter category?
-
Hello I use jetpack portfolio with some categories. On the main portfolio page I use the filter panel with all categories to select. Now I want to show on this page only the posts with a specific category. I want to preselect the filter via a GET parameter in the url.
So this is my approach via JS:
function trigger_projekte(type = '') { if (type != "") { var filterButton = jQuery('.cbp-filter-item[data-filter*="'+type+'"]'); if (filterButton.length > 0) { setTimeout(function(){ filterButton.trigger('click'); }, 1000); } } } jQuery(window).on("load", function(){ trigger_projekte("'.$show.'"); });
The problem is, that the trigger only works when I have a small amount of posts.
Is there a possibilty to preselect the filter panel via JS or in PHP?
Is there maybe another eventlistener I can listen to, for example when all posts are loaded, then fire my function?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Jetpack Portfolio: How to trigger filter category?’ is closed to new replies.