AJAX, Chips list, Filters button, Auto scroll
If you have one of these problems:
- AJAX feature doesn’t work properly
- Button that opens Filters widget doesn’t appear (Please, read this)
- Selected terms (aka Chips list) doesn’t appear above the posts container
- Auto scroll to the top of the posts grid doesn’t work
you can try to to specify correct values that match your theme and place the code below to the functions.php file of your theme.
All values in the config array are optional and you can set only the ones you need.
add_filter( 'wpc_theme_dependencies', 'my_theme_dependencies' );
function my_theme_dependencies( $theme_dependencies ){
/* my_theme_folder_name - name of the directory of your current WordPress
theme. All letters should be lowercase even if the theme directory
has uppercase letters. If you use child theme, you should specify
parent theme name */
$theme_dependencies['my_theme_folder_name'] = array(
// HTML selector of the container included posts. E.g. '#primary' or
// '.main-wrapper .posts'
'posts_container' => '#primary',
// Primary color of your theme. E.g. '#ff0000'
'primary_color' => '#cc0000',
// Array with names of the do_action() hooks of your theme, where you want
// to display button, that opens Filters widget E.g. 'before_main_content'
'button_hook' => array('generate_before_main_content'),
// Array with names of the do_action() hooks of your theme, where you want
// to display chips. E.g. 'before_posts_list'
// Don't forget to add Chips list on the 404 page.
'chips_hook' => array(
'generate_before_posts_list',
'generate_no_posts_found'
)
);
return $theme_dependencies;
}
Multiple Filter Sets on the same page
Sometimes, there is a need to put more than one Filter Set on a page. For example, when you have Products and News posts on the same page and want to filter both. Firstly, you should create two Filter Sets and place them on the required pages. Secondly, to display both of them, you must insert two Filter Widgets or two shortcodes [fe_widget].
If you want to set the order in which Filter Sets are displayed – first, second, … – you can use the “Priority” parameter inside the Filter Set settings. The Filter Set with the higher priority will be displayed first.
Change -Select- text in dropdowns
You can use this code example, placing it in the functions.php file of your theme or using the code snippets plugin:
// Define a custom function to modify the default option text
function custom_dropdown_default_option($default_option, $filter) {
// Modify the default option text as needed
$modified_default_option = sprintf(__('My custom text: %s', 'filter-everything'), $filter['label']);
return $modified_default_option;
}
// Hook the custom function to the 'wpc_dropdown_default_option' filter
add_filter('wpc_dropdown_default_option', 'custom_dropdown_default_option', 10, 2);
Change the “My custom text: ” to the needed text. The “%s” will show your attribute/taxonomy/custom field title name.
Change the number of filter terms before See more
Go to the Filters → Settings → Experimental → Custom CSS and add the next code:
.wpc-filter-more-less:not(.wpc-search-active) .wpc-filters-ul-list > li:nth-child(-n+6) {
display: list-item;
}
Change the “(-n+6)” to the needed number (you need to change only the number)
Redirection filter step-by-step instruction
1. For example, you have a “Home” page and a “Shop” page, and you wish to apply a redirection filter on the “Home” page which will redirect you to the “Shop” page.
2. Create a “Filter Set” for the “Home” page with the required filters. In the “Where to filter” dropdowns, choose the “Shop” page, and in the “And what to filter” section, select the appropriate WP_Query.
3. Scroll down to the “Apply Button” mode and activate it. If you set your page as a homepage from the WP admin dashboard, then select “Common WordPress Pages” + “Homepage” in the “Alternative Location” dropdowns. If not, choose “Pages” + “Your Page Name” – the page where you want to display your redirection filter and hit the create/update button.
4. Now, when you select the necessary filter terms on the “Home” page and click the “Apply” button, you will be redirected to the “Shop” page with the selected filter terms applied.
5. Create one more “Filter Set” with the necessary filters and place it on the “Shop” page, since there won’t be any filters. Kindly ensure that you have added all the filters that were present in the redirection “Filter Set” or even more. For instance, if the redirection “Filter Set” contains a year filter, it should also be included in the products “Filter Set”.
6. Done! You have a redirection filter on the “Home” page that sends you to the “Shop” page, where you can place a complete “Filter Set”. All chosen terms from the redirection filter will be applied.