Filter term name hooks
Allow to change filter’s term html in Filter widget.
/* Post meta term name */
apply_filters('wpc_filter_post_meta_term_name', $term_name, $entity_name);
/* Post meta exists term name */
apply_filters('wpc_filter_post_meta_exists_term_name', $term_name, $entity_name);
/* Post meta num term name */
apply_filters('wpc_filter_post_meta_num_term_name', $term_name, $entity_name);
/* Taxonomy term name */
apply_filters('wpc_filter_taxonomy_term_name', $term_name, $entity_name);
/* Author term name */
apply_filters('wpc_filter_author_term_name', $term_name, $entity_name);
Usage Example
/**
* Let's capitalize all terms for Product type
* and Product visibility
*/
add_filter('wpc_filter_taxonomy_term_name', 'wpc_modify_taxonomy_term_name', 10, 2 );
function wpc_modify_taxonomy_term_name($term_name, $e_name)
{
if (in_array($e_name, array('product_type', 'product_visibility'))) {
$term_name = ucfirst($term_name);
}
return $term_name;
}
Parameters
$term_name(string) Term name$entity_name(string) Term entity name ( taxonomy name, author or post meta key )
Filter term html hooks
Allow to change filter term html in Filters widget.
/* Checkbox term html */
apply_filters( 'wpc_filters_checkbox_term_html', '<a '.$link_attributes.'>'.$term_object->name.'</a>', $link_attributes, $term_object, $filter );
/* Label term html */
apply_filters( 'wpc_filters_label_term_html', '<a '.$link_attributes.'>'.$term_object->name.'</a>', $link_attributes, $term_object, $filter );
/* Radio term html */
apply_filters( 'wpc_filters_radio_term_html', '<a '.$link_attributes.'>'.$term_object->name.'</a>', $link_attributes, $term_object, $filter );
Usage Example
/* Let's add Apple logo for 'apple' brand term */
add_filter( 'wpc_filters_checkbox_term_html', 'wpc_term_brand_logo', 10, 4 );
function wpc_term_brand_logo($html, $link_attributes, $term, $filter){
if( $term->slug === 'apple' ){
$img = '<img src="'.plugin_dir_url(__FILE__).'/img/apple.svg" alt="Apple logo" width="15" height="15" />';
$html = '<a '.$link_attributes.'>'.$img . ' '. $term->name.'</a>';
}
return $html;
}
Parameters
$html(string) Term html$link_attributes(string) Term link attributes$term(object) Term object$filter(array) Filter parameters
Terms filter before display
Allows to modify terms list before displaying them in the widget.
$terms = apply_filters( 'wpc_terms_before_display', $terms, $filter, $set, $urlManager );
Usage Example
/* Let's sort Color filter terms by the menu_order */
add_filter('wpc_terms_before_display', 'wpc_sort_terms_as_needed', 10, 2);
function wpc_sort_terms_as_needed($terms, $filter){
// pa_color - is desired taxonomy
if ($filter['e_name'] === 'pa_color') {
$newTerms = [];
foreach ($terms as $k => $term) {
$termOrder = get_term_meta($term->term_id, 'order', true);
$term->menu_order = ($termOrder !== false) ? $termOrder : 0;
$newTerms[$k] = $term;
}
// To sort in descending order
// usort( $newTerms, \FilterEverything\Filter\EntityManager::compareDesc('menu_order') );
// To sort in ascending order
usort($newTerms, \FilterEverything\Filter\EntityManager::compareAsc('menu_order'));
return $newTerms;
}
return $terms;
}
Parameters
$terms(array) List of term objects$filter(array) Current Filter parameters$set(array) Filter Set fields with parameters$urlManager(object) Of the UrlManager Class, that can be used to get the link to the filter
SEO var filter
Allows to change SEO var value. Works for all SEO var values: SEO title, Meta description, H1 title, Page description.
apply_filters( 'wpc_seo_var_term_name', $term_name, $entity_name );
Usage Example
Before applying this code H1 title was “Buy apple smartphones in Paris”
After applying became “Buy Apple smartphones in Paris”
/* Let's capitalize Brand SEO vars */
add_filter('wpc_seo_var_term_name', 'wpc_uppercase_brand_seo_vars', 10, 2);
function wpc_uppercase_brand_seo_vars( $term_name, $entity_name )
{
if( 'pa_brand' === $entity_name ){
return ucfirst($term_name);
}
return $term_name;
}
Parameters
$term_name(string) Term name$entity_name(string) Term entity name ( taxonomy name, author or post meta key )
Auto Scroll offset
Allows you to change the position to which the Auto scroll is scrolled.
apply_filters( 'wpc_auto_scroll_offset', 150 );
Usage Example
add_filter('wpc_auto_scroll_offset', 'wpc_change_auto_scroll_offset');
function wpc_change_auto_scroll_offset( $offset ){
return 200;
}
Parameters
$offset(int) Scroll offset in pixels from the top of posts container
SEO data hooks (from v 1.3.2)
Allow you to change SEO data values on filtering pages.
/* SEO title */
apply_filters( 'wpc_seo_title', $seoTitle );
/* SEO description */
apply_filters( 'wpc_seo_description', $description );
/* SEO robots */
apply_filters( 'wpc_seo_robots', $robots_strings );
/* SEO canonical */
apply_filters( 'wpc_seo_canonical', $canonical );
/* SEO h1 */
apply_filters( 'wpc_seo_h1', $h1);
/* SEO text */
apply_filters( 'wpc_seo_text', $seoText );
Usage Example
/**
* Let's capitalize titles on filtering pages
*/
add_filter('wpc_seo_title', 'wpc_modify_seo_title' );
function wpc_modify_seo_title($title)
{
return ucfirst($title);
}
Filters Widget hooks (from v 1.6.0)
Allow you to do any actions before and after Filters widget.
/* Before Filters widget */
do_action( 'wpc_before_filters_widget', $args, $instance );
/* After Filters widget */
do_action( 'wpc_after_filters_widget', $args, $instance );
/* Before display Filters widget */
do_action( 'wpc_before_display_filters_widget', $setId, $args, $instance );
Usage Example
/**
* Show additional title before Filters widget
*/
add_action('wpc_before_filters_widget', 'my_filters_widget' );
function my_filters_widget($args)
{
echo 'My special title
'."\r\n";
}
Parameters
$args(array) Widget args like widget name, class etc$instance(array) Widget settings$setId(string) Filter Set ID