Filters
Filters provide a flexible way to modify project elements in the child-theme’s functions.php file without requiring a copy of a template file. This ensures an update-proof approach to customization while allowing for creative adjustments.
How it works
Many classes and other elements are wrapped in filters, enabling modifications without storing template copies in a child theme. A basic filter consists of:
- A filter name, e.g.,
bootscore/example/filter/name - A returnable value, such as a string containing one or more CSS classes
<div class="<?= esc_attr(apply_filters('bootscore/example/filter/name', 'one or more classes')); ?>">
...
</div>Result in frontend:
<div class="one or more classes">
...
</div>To modify these classes via a child theme, a custom function is required. This function must:
- Have a unique function name
my_fancy_filter_function - Return the modified value (in this case, CSS classes)
- Be hooked into the appropriate filter
bootscore/example/filter/name
/**
* Change one or more classes into my-custom-class
*/
function my_fancy_filter_function() {
return "my-custom-class";
}
add_filter('bootscore/example/filter/name', 'my_fancy_filter_function', 10, 2);Result in frontend
<div class="my-custom-class">
...
</div>Location
When a filter is used in multiple files, an additional location argument can specify where it is applied:
<?= esc_attr(apply_filters('bootscore/example/filter/name', 'one or more classes', 'location-in-which-template-this-filter-is-used')); ?>For example, the bootscore/class/container filter is present in several template files:
In header.php:
<?= esc_attr(apply_filters('bootscore/class/container', 'container', 'header')); ?>In archive.php:
<?= esc_attr(apply_filters('bootscore/class/container', 'container', 'archive')); ?>Applying a basic filter without specifying a location modifies all instances:
/**
* Change entire container classes
*/
function change_entire_containers() {
return "container-fluid";
}
add_filter('bootscore/class/container', 'change_entire_containers', 10, 2);To modify only a specific instance, the location parameter can be checked:
/**
* Change container class in a single file
*/
function change_container_in_single_file($string, $location) {
if ($location == 'header') {
return "container-fluid";
}
return $string;
}
add_filter('bootscore/class/container', 'change_container_in_single_file', 10, 2);For multiple locations, conditions can be expanded:
/**
* Change container classes in selected files
*/
function change_container_in_selected_files($string, $location) {
if ($location == 'header' || $location == 'footer-top' || $location == 'footer-columns' || $location == 'footer-info') {
return "container-fluid";
}
return $string;
}
add_filter('bootscore/class/container', 'change_container_in_selected_files', 10, 2);Filters reference list
bootscore/class/header
header.phpbootscore/class/header/navbar/breakpoint
header.phpbootscore/class/container($location)
header.php, 404.php, archive.php, footer.php, index.php, page.php, search.php, single.php, woocommerce.php, /page-templates/page-blank-container.php, /page-templates/page-full-width-image.php, /page-templates/page-sidebar-none.php, /page-templates/page-sidebar-left.php, /single-templates/single-full-width-image.php, /single-templates/single-sidebar-left.php, /single-templates/single-sidebar-none.php, /template-parts/header/collapse-search-woocommerce.php, /template-parts/header/collapse-search.phpbootscore/class/header/navbar-brand
header.phpbootscore/logo
header.phpbootscore/class/header/offcanvas/direction($location)
header.php, /template-parts/header/offcanvas-woocommerce.phpbootscore/class/offcanvas/header($location)
header.php, sidebar.php, /template-parts/header/offcanvas-woocommerce.phpbootscore/offcanvas/navbar/title
header.phpbootscore/class/offcanvas/body($location)
header.php, sidebar.php, /template-parts/header/offcanvas-woocommerce.phpbootscore/class/header-actions
header.phpbootscore/class/header/button($location)
header.php, /template-parts/header/actions-woocommerce.php, /template-parts/header/actions.phpbootscore/class/header/navbar/toggler/breakpoint
header.phpbootscore/class/header/action/spacer($location)
header.php, /template-parts/header/actions.php, /template-parts/header/actions-woocommerce.php, /inc/widgets.phpbootscore/class/header/top-nav-widget-2
/inc/widgets.phpbootscore/class/header/search/breakpoint
/template-parts/header/actions.php, /template-parts/header/collapse-search.phpbootscore/class/header/navbar-nav
/template-parts/header/main-menu.phpbootscore/offcanvas/account/title
/template-parts/header/offcanvas-woocommerce.phpbootscore/offcanvas/cart/title
/template-parts/header/offcanvas-woocommerce.phpbootscore/disable/unsupported/blocks(false)
functions.phpbootscore/class/cart/product-title
/woocommerce/cart/mini-cart-item.phpbootscore/class/cart/enable_cart_product_excerpt(true)
/woocommerce/cart/mini-cart-item.phpbootscore/class/cart/product-excerpt
/woocommerce/cart/mini-cart-item.phpbootscore/class/cart/enable_cart_stock_quantity(true)
/woocommerce/cart/mini-cart-item.phpbootscore/class/header/cart/footer
/woocommerce/cart/mini-cart.phpbootscore/woocommerce/ajax-cart/update-qty/fragments/replace
/woocommerce/inc/ajax-cart.phpbootscore/woocommerce/ajax-cart/update-qty/response/before-update
/woocommerce/inc/ajax-cart.phpbootscore/woocommerce/ajax-cart/update-qty/response/after-update
/woocommerce/inc/ajax-cart.phpbootscore/woocommerce/ajax-cart/update-qty/validate-update
/woocommerce/inc/ajax-cart.phpbootscore/woocommerce/ajax-cart/update-qty/response/force-full-refresh(true)
/woocommerce/inc/ajax-cart.phpbootscore/class/woocommerce/toast-container
/woocommerce/inc/ajax-cart.phpbootscore/woocommerce/loop/out-of-stock-remove-read-more(false)
/woocommerce/inc/ajax-cart.phpbootscore/woocommerce/loop/show-out-of-stock-badge(true)
/woocommerce/inc/ajax-cart.phpbootscore/class/woocommerce/loop/out-of-stock-badge
/woocommerce/inc/ajax-cart.phpbootscore/block/product/filters/content
woocommerce/inc/blocks/wc-block-widget-product-filters.phpbootscore/class/woocommerce/product/card
woocommerce/content-product.php, woocommerce/content-product-cat.phpbootscore/class/woocommerce/product/card/card-body
woocommerce/content-product.php, woocommerce/content-product-cat.phpbootscore/class/reviews/tab-badge
woocommerce/inc/wc-tabs.phpbootscore/class/woocommerce/loop/add-to-cart
woocommerce/inc/wc-loop.phpbootscore/class/woocommerce/product/loop/img
woocommerce/inc/wc-loop.phpbootscore/class/woocommerce/category/loop/img
woocommerce/inc/wc-loop.phpbootscore/class/woocommerce/loop/add-to-cart/button
woocommerce/inc/wc-loop.phpbootscore/class/breadcrumb/nav
/inc/breadcrumb.phpbootscore/class/breadcrumb/ol
/inc/breadcrumb.phpbootscore/class/breadcrumb/item/link
/inc/breadcrumb.php, /woocommerce/inc/wc-breadcrumb.phpbootscore/breadcrumb/handler
/inc/breadcrumb.php, /woocommerce/inc/wc-breadcrumb.phpbootscore/woocommerce/header/show_cart_total(true)
/woocommerce/inc/wc-mini-cart.phpbootscore/class/header/cart/badge
/woocommerce/inc/wc-mini-cart.phpbootscore/class/header/cart/total
/woocommerce/inc/wc-mini-cart.phpbootscore/class/main/col
archive.php, index.php, page.php, search.php, single.php, woocommerce.php, /inc/columns.php, /page-templates/page-full-width-image.php, /page-templates/page-sidebar-left.php, /single-templates/single-full-width-image.php, /single-templates/single-full-width-image.php, /single-templates/single-sidebar-left.phpbootscore/class/entry/title($location)
404.php, archive.php, index.php, page.php, search.php, single.php, /page-templates/page-full-width-image.php, /page-templates/page-sidebar-left.php, /page-templates/page-sidebar-none.php, /single-templates/single-full-width-image.php, /single-templates/single-sidebar-left.php, /single-templates/single-sidebar-none.phpbootscore/class/entry/archive-description
archive.phpbootscore/class/content/spacer($location)
404.php, archive.php, index.php, page.php, search.php, single.php, /page-templates/page-full-width-image.php, /page-templates/page-sidebar-left.php, /page-templates/page-sidebar-none.php, /single-templates/single-full-width-image.php, /single-templates/single-sidebar-left.php, /single-templates/single-sidebar-none.phpbootscore/class/featured-full-width-img($location)
/page-templates/page-full-width-image.php, /single-templates/single-full-width-image.phpbootscore/class/full-width-img-title-wrapper($location)
/page-templates/page-full-width-image.php, /single-templates/single-full-width-image.phpbootscore/class/loop/card($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/card/row($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/card/image/col($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/card/image($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/card/content/col($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/card/body($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/loop/category(true,$location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/card/content/meta-wrapper
index.phpbootscore/class/loop/card/content/sticky-post-badge
index.phpbootscore/class/loop/card/title/link($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/card/title($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/loop/meta(true,$location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/loop/excerpt(true,$location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/card-text/excerpt/link($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/card-text/excerpt($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/loop/read-more(true,$location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/card-text/read-more($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/loop/read-more($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/loop/read-more/text($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/loop/tags(true,$location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore/class/sidebar/col
sidebar.phpbootscore/class/sidebar/button
sidebar.phpbootscore/offcanvas/sidebar/button/text
sidebar.phpbootscore/class/sidebar/offcanvas
sidebar.phpbootscore/offcanvas/sidebar/title
sidebar.phpbootscore/block/archives/content
/inc/blocks/block-widget-archives.phpbootscore/block/code/content
/inc/blocks/block-code.phpbootscore/block/calendar/content
/inc/blocks/block-widget-calendar.phpbootscore/block/categories/content
/inc/blocks/block-widget-categories.phpbootscore/block/latest-comments/content
/inc/blocks/block-widget-latest-comments.phpbootscore/block/latest-posts/content
/inc/blocks/block-widget-latest-posts.phpbootscore/class/widget/search/button($location)
searchform.php, /inc/blocks/block-widget-search.phpbootscore/block/search/content
/inc/blocks/block-widget-search.phpbootscore/block/table/content
/inc/blocks/block-table.phpbootscore/class/block/table
/inc/blocks/block-table.phpbootscore/icon/menu
header.phpbootscore/icon/search($location)
searchform.php, /inc/blocks/block-widget-search.php, /template-parts/header/actions.php, /template-parts/header/actions-woocommerce.phpbootscore/icon/user
/template-parts/header/actions-woocommerce.phpbootscore/icon/arrow-left
/template-parts/header/actions-woocommerce.phpbootscore/icon/cart
/template-parts/header/actions-woocommerce.phpbootscore/icon/trash
/woocommerce/cart/mini-cart.phpbootscore/icon/chevron-up
footer.phpbootscore/icon/home
/inc/breadcrumb.phpbootscore/icon/comments
/inc/template-tags.phpbootscore/class/comment/avatar
comments.php, /woocommerce/single-product/review.phpbootscore/class/comments/closed/alert
comments.phpbootscore/comments/closed/text
comments.phpbootscore/class/badge/category
/inc/template-tags.phpbootscore/meta/time/updated
/inc/template-tags.phpbootscore/meta/author
/inc/template-tags.phpbootscore/class/badge/tag
/inc/template-tags.phpbootscore/icon/tag
/inc/template-tags.phpbootscore/show/tag/icon(true)
/inc/template-tags.phpbootscore/class/footer/top
footer.phpbootscore/class/footer/columns
footer.phpbootscore/class/footer/col($location)
footer.phpbootscore/class/footer/col/spacer($location)
/inc/widgets.phpbootscore/class/footer/info
footer.phpbootscore/class/footer/to_top_button
footer.phpbootscore/load_fontawesome(true)
/inc/enqueue.phpbootscore/skip_cart(false)
/template-parts/header/actions-woocommerce.php, /woocommerce/wc-functions.phpbootscore/load_ajax_cart(true)
/woocommerce/wc-functions.phpbootscore/wc_ajax_login(true)
/template-parts/header/offcanvas-woocommerce.php, /woocommerce/wc-functions.phpbootscore/scss/skip_environment_check(false)
/inc/scss-compiler.phpbootscore/scss/disable_compiler(false)
/inc/scss-compiler.phpbootscore/scss/compiler
/inc/scss-compiler.php
Actions
While filters modify existing content, actions are used to add new elements. Actions can be used for various tasks, such as inserting a message, opening a <div> in one action and closing it in another, or adding more complex functionality.
How it works
A basic action looks like this:
<?php do_action( 'bootscore_before_masthead' ); ?>To add content at this action hook, the following are required:
- An unique function name (e.g.,
my_fancy_action_function) - The action name (e.g.,
bootscore_before_masthead) - An
echostatement to output content
/**
* Add an alert message before the masthead.
*/
function add_alert_before_masthead() {
echo '<div class="alert alert-danger" role="alert">This is an important message!</div>';
}
add_action('bootscore_before_masthead', 'add_alert_before_masthead');Location
When an action is used in multiple files, an additional location argument can specify where it is applied:
<?php do_action( 'bootscore_after_primary_open', 'page-sidebar-left' ); ?>Applying a basic action without specifying a location adds content to all instances:
/**
* Add an alert message after primary open.
*/
function add_alert_after_primary_open() {
echo '<div class="alert alert-danger" role="alert">This is an important message!</div>';
}
add_action('bootscore_after_primary_open', 'add_alert_after_primary_open');To modify only a specific instance, the location parameter can be checked:
/**
* Add an alert message after primary open for 'page-sidebar-left' location.
*/
function add_alert_after_primary_open($location) {
if ($location == 'page-sidebar-left') {
echo '<div class="alert alert-warning" role="alert">This is a warning alert for page-sidebar-left!</div>';
}
}
add_action('bootscore_after_primary_open', 'add_alert_after_primary_open');For multiple locations, the conditions can be expanded:
/**
* Add an alert message after primary open for 'page-sidebar-left' and 'archive' location.
*/
function add_alert_after_primary_open($location) {
if ($location == 'page-sidebar-left' || $location == 'archive') {
echo '<div class="alert alert-warning" role="alert">This is a warning alert for page-sidebar-left and archive!</div>';
}
}
add_action('bootscore_after_primary_open', 'add_alert_after_primary_open');Visual guide
The following snippet will hook an alert alert-warning to all actions to create a visual map, as shown in the screenshot in header.php. If an action has a location, it will also be displayed.

/**
* Generate hooks for all Bootscore actions
*/
$bootscore_hooks = [
'bootscore_before_masthead',
'bootscore_after_masthead_open',
'bootscore_before_navbar_brand',
'bootscore_after_navbar_brand',
'bootscore_after_nav_toggler',
'bootscore_before_masthead_close',
'bootscore_after_masthead',
'bootscore_after_primary_open',
'bootscore_before_title',
'bootscore_after_title',
'bootscore_before_loop',
'bootscore_before_loop_item',
'bootscore_before_loop_thumbnail',
'bootscore_after_loop_thumbnail',
'bootscore_before_loop_title',
'bootscore_after_loop_title',
'bootscore_after_loop_tags',
'bootscore_loop_item_after_card_body',
'bootscore_after_loop_item',
'bootscore_after_loop',
'bootscore_after_featured_image',
'bootscore_before_entry_footer',
'bootscore_before_pagination',
'bootscore_before_sidebar_widgets',
'bootscore_after_sidebar_widgets',
'bootscore_before_my_offcanvas_account',
'bootscore_before_footer',
'bootscore_footer_columns_before_container',
'bootscore_footer_columns_after_container_open',
'bootscore_footer_columns_before_container_close',
'bootscore_footer_columns_after_container',
'bootscore_footer_info_after_container_open',
'bootscore_before_mini_cart_footer',
];
// Add hooks dynamically
foreach ($bootscore_hooks as $hook) {
add_action($hook, function ($location = null) use ($hook) {
$output = '<div class="alert alert-warning"><code>' . esc_html($hook) . '</code>';
if ($location) {
$output .= ' (Location: <strong>' . esc_html($location) . '</strong>)';
}
$output .= '</div>';
echo $output;
});
}Action reference list
bootscore_before_masthead
header.phpbootscore_after_masthead_open
header.phpbootscore_before_navbar_brand
header.phpbootscore_after_navbar_brand
header.phpbootscore_after_nav_toggler
header.phpbootscore_before_masthead_close
header.phpbootscore_after_masthead
header.phpbootscore_after_primary_open($location)
404.php, archive.php, index.php, page.php, search.php, single.php, woocommerce.php, /page-templates/page-full-width-image.php, /page-templates/page-sidebar-left.php, /page-templates/page-sidebar-none.php, /single-templates/single-full-width-image.php, /single-templates/single-sidebar-left.php, /single-templates/single-sidebar-none.phpbootscore_before_title($location)
404.php, archive.php, index.php, page.php, search.php, single.php, /page-templates/page-full-width-image.php, /page-templates/page-sidebar-left.php, /page-templates/page-sidebar-none.php, /single-templates/single-full-width-image.php, /single-templates/single-sidebar-left.php, /single-templates/single-sidebar-none.phpbootscore_after_title($location)
404.php, archive.php, index.php, page.php, search.php, single.php, /page-templates/page-full-width-image.php, /page-templates/page-sidebar-left.php, /page-templates/page-sidebar-none.php, /single-templates/single-full-width-image.php, /single-templates/single-sidebar-left.php, /single-templates/single-sidebar-none.phpbootscore_before_loop($location)
archive.php, index.php, search.php, /template-parts/search/content-search.phpbootscore_before_loop_item($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore_before_loop_thumbnail($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore_after_loop_thumbnail($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore_before_loop_title($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore_after_loop_title($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore_after_loop_tags($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore_loop_item_after_card_body($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore_after_loop_item($location)
archive.php, index.php, /template-parts/search/content-search.phpbootscore_after_loop($location)
archive.php, index.php, search.php, /template-parts/search/content-search.phpbootscore_after_featured_image($location)
page.php, single.php, /page-templates/page-full-width-image.php, /page-templates/page-sidebar-left.php, /page-templates/page-sidebar-none.php, /single-templates/single-full-width-image.php, /single-templates/single-sidebar-left.php, /single-templates/single-sidebar-none.phpbootscore_before_entry_footer($location)
page.php, single.php, /page-templates/page-full-width-image.php,/page-templates/page-sidebar-left.php, /page-templates/page-sidebar-none.php, /single-templates/single-full-width-image.php, /single-templates/single-sidebar-left.php, /single-templates/single-sidebar-none.phpbootscore_before_pagination($location)
single.php, /single-templates/single-full-width-image.php, /single-templates/single-sidebar-left.php, /single-templates/single-sidebar-none.php, archive.php, index.php, search.phpbootscore_before_sidebar_widgets
sidebar.php.phpbootscore_after_sidebar_widgets
sidebar.php.phpbootscore_before_my_offcanvas_account
/template-parts/header/offcanvas-woocommerce.phpbootscore_before_footer
footer.phpbootscore_footer_columns_before_container
footer.phpbootscore_footer_columns_after_container_open
footer.phpbootscore_footer_columns_after_container_open
footer.phpbootscore_footer_columns_before_container_close
footer.phpbootscore_footer_columns_after_container
footer.phpbootscore_footer_info_after_container_open
footer.phpbootscore_before_mini_cart_footer
/woocommerce/cart/mini-cart.php
Examples
Install a fresh child and copy each example to functions.php, see what it does in the frontend and learn by changing the classes.
Icons
/**
* Change nav-toggler icon
*/
function change_nav_toggler_icon() {
return '<i class="fa-solid fa-ellipsis-vertical"></i>';
}
add_filter('bootscore/icon/menu', 'change_nav_toggler_icon');
/**
* Change search-toggler icon
*/
function change_search_toggler_icon() {
return '<i class="fa-solid fa-glasses"></i>';
}
add_filter('bootscore/icon/search', 'change_search_toggler_icon');
/**
* Change account-toggler user icon
*/
function change_account_toggler_icon() {
return '<i class="fa-solid fa-right-to-bracket"></i>';
}
add_filter('bootscore/icon/user', 'change_account_toggler_icon');
/**
* Change cart-toggler bag icon
*/
function change_cart_toggler_icon() {
return '<i class="fa-solid fa-cart-shopping"></i>';
}
add_filter('bootscore/icon/cart', 'change_cart_toggler_icon');
/**
* Change back-to-cart-toggler arrow icon
*/
function change_back_to_cart_arrow_icon() {
return '<i class="fa-solid fa-angles-left"></i>';
}
add_filter('bootscore/icon/arrow-left', 'change_back_to_cart_arrow_icon');
/**
* Change sidebar offcanvas-toggler icon
*/
function change_sidebar_toggler_icon() {
return '<i class="fa-solid fa-ellipsis"></i>';
}
add_filter('bootscore/icon/ellipsis-vertical', 'change_sidebar_toggler_icon');
/**
* Change WooCommerce mini-cart trash icon
*/
function change_trash_icon() {
return '<i class="fa-solid fa-xmark"></i>';
}
add_filter('bootscore/icon/trash', 'change_trash_icon');
/**
* Change star icon
*/
function change_star_icon() {
return '<i class="fa-solid fa-map-pin"></i>';
}
add_filter('bootscore/icon/star', 'change_star_icon');
/**
* Change comments icon
*/
function change_comments_icon() {
return '<i class="fa-solid fa-message"></i>';
}
add_filter('bootscore/icon/comments', 'change_comments_icon');
/**
* Change breadcrumb home icon
*/
function change_home_icon() {
return '<i class="fa-solid fa-igloo"></i>';
}
add_filter('bootscore/icon/home', 'change_home_icon');
/**
* Change to-top button icon
*/
function change_to_top_icon() {
return '<i class="fa-solid fa-arrow-up"></i>';
}
add_filter('bootscore/icon/chevron-up', 'change_to_top_icon');
/**
* Change tag icon
*/
function change_tag_icon() {
return '<i class="fa-solid fa-hashtag"></i>';
}
add_filter('bootscore/icon/tag', 'change_tag_icon');Header
Change paths to logos
/**
* Change path to logos
*/
function change_logo_path($logo, $color) {
if ($color === 'theme-dark') {
return get_stylesheet_directory_uri() . '/path/to/dark-logo.png';
}
return get_stylesheet_directory_uri() . '/path/to/default-logo.png';
}
add_filter('bootscore/logo', 'change_logo_path', 10, 2);Position and bg
/**
* Header position and bg
*/
function header_bg_class() {
return "position-relative bg-body shadow-sm";
}
add_filter('bootscore/class/header', 'header_bg_class', 10, 2);
/**
* Header search collapse position and bg
*/
function header_collapse_bg_class() {
return "bg-body shadow-sm position-absolute start-0 end-0";
}
add_filter('bootscore/class/header/collapse', 'header_collapse_bg_class', 10, 2);Breakpoints
Change navbar expand to md:
/**
* Header navbar breakpoint
*/
function header_navbar_breakpoint_class() {
return "navbar-expand-md";
}
add_filter('bootscore/class/header/navbar/breakpoint', 'header_navbar_breakpoint_class', 10, 2);
/**
* Header navbar toggler breakpoint
*/
function header_navbar_toggler_breakpoint_class() {
return "d-md-none";
}
add_filter('bootscore/class/header/navbar/toggler/breakpoint', 'header_navbar_toggler_breakpoint_class', 10, 2);Navbar always collapsed:
/**
* Header navbar breakpoint
*/
function header_navbar_breakpoint_class() {
return "";
}
add_filter('bootscore/class/header/navbar/breakpoint', 'header_navbar_breakpoint_class', 10, 2);
/*
* Header navbar toggler breakpoint
*/
function header_navbar_toggler_breakpoint_class() {
return "";
}
add_filter('bootscore/class/header/navbar/toggler/breakpoint', 'header_navbar_toggler_breakpoint_class', 10, 2);Buttons
Change all header button classes at once:
/**
* Change all header buttons
*/
function header_button_class() {
return "btn btn-light";
}
add_filter('bootscore/class/header/button', 'header_button_class', 10, 2);Change a single button class only. For example the navbar-toggler:
/**
* Change single header button
*/
function header_button_class($string, $location) {
if ($location == 'nav-toggler') {
return "btn btn-light";
}
return $string;
}
add_filter('bootscore/class/header/button', 'header_button_class', 10, 2);Or select multiple buttons. For example account-toggler and mini-cart-toggler:
/**
* Change selected header buttons
*/
function header_button_class($string, $location) {
if ($location == 'account-toggler' || $location == 'cart-toggler') {
return "btn btn-light";
}
return $string;
}
add_filter('bootscore/class/header/button', 'header_button_class', 10, 2);Navbar offcanvas title
/**
* Change navbar offcanvas title
*/
function change_navbar_offcanvas_title($title) {
return 'My Menu';
}
add_filter('bootscore/offcanvas/navbar/title', 'change_navbar_offcanvas_title');Add a mobile logo, center the logo and move menu to left
/**
* Header hook a mobile logo
*/
function hook_before_navbar_brand() {
?>
<a class="position-absolute top-50 start-50 translate-middle d-sm-none" href="<?= esc_url(home_url()); ?>">
<img src="<?= esc_url(get_stylesheet_directory_uri()); ?>/assets/img/logo/logo-sm.svg" alt="<?php bloginfo('name'); ?> Logo" class="d-td-none">
<img src="<?= esc_url(get_stylesheet_directory_uri()); ?>/assets/img/logo/logo-sm-theme-dark.svg" alt="<?php bloginfo('name'); ?> Logo" class="d-tl-none">
</a>
<?php
}
add_action( 'bootscore_before_navbar_brand', 'hook_before_navbar_brand' );
/**
* Header navbar-brand
*/
function header_navbar_brand_class() {
return "position-absolute top-50 start-50 translate-middle d-none d-sm-block";
}
add_filter('bootscore/class/header/navbar-brand', 'header_navbar_brand_class', 10, 2);
/**
* Header menu position
*/
function header_navbar_menu_class() {
return "ms-start";
}
add_filter('bootscore/class/header/navbar-nav', 'header_navbar_menu_class', 10, 2);
/**
* Header actions
*/
function header_actions_class() {
return "d-flex align-items-center flex-grow-1 justify-content-lg-end";
}
add_filter('bootscore/class/header-actions', 'header_actions_class', 10, 2);
/**
* Move nav-toggler to first
*/
function header_nav_toggler_button_spacer_class($string, $location) {
if ($location == 'nav-toggler') {
return "order-first me-auto";
}
return $string;
}
add_filter('bootscore/class/header/action/spacer', 'header_nav_toggler_button_spacer_class', 10, 2);
/**
* Change header menu offcanvas direction
*/
function header_menu_offcanvas_directions($string, $location) {
if ($location == 'menu') {
return "start";
}
return $string;
}
add_filter('bootscore/class/header/offcanvas/direction', 'header_menu_offcanvas_directions', 10, 2);
Search collapse breakpoint (if WooCommerce is not installed)
/**
* Change search collapse breakpoint if WooCommerce is not installed
* Leave breakpoint empty to keep search always collapsed
*/
function change_search_collapse_breakpoint() {
return 'xxl';
}
add_filter('bootscore/class/header/search/breakpoint', 'change_search_collapse_breakpoint');Breadcrumb
Change general layout
/**
* Change breadcrumb <nav> classes
*/
function change_breadcrumb_nav_class() {
return 'overflow-x-auto text-nowrap mb-4 mt-2 py-2 px-3 border rounded';
}
add_filter('bootscore/class/breadcrumb/nav', 'change_breadcrumb_nav_class');
/**
* Change breadcrumb <ol> classes
*/
function change_breadcrumb_ol_class() {
return 'flex-nowrap mb-0';
}
add_filter('bootscore/class/breadcrumb/ol', 'change_breadcrumb_ol_class');
/**
* Change breadcrumb <a> classes
*/
function change_breadcrumb_a_class() { return 'text-decoration-none link-danger';
}
add_filter('bootscore/class/breadcrumb/item/link', 'change_breadcrumb_a_class');Add breadcrumb to pages, search results and archives
Bootscore follows the WordPress standard and only displays breadcrumbs on single posts (where they’re most commonly needed). However, breadcrumbs can easily added to pages, archives, search results, and custom templates using the available action hooks.
/**
* Hook breadcrumb to 'page-full-width-image.php'
*/
function hook_breadcrumb_to_page_full_width_image( $location ) {
if ( $location === 'page-full-width-image' ) {
the_breadcrumb();
}
}
add_action( 'bootscore_after_featured_image', 'hook_breadcrumb_to_page_full_width_image');
/**
* Hook breadcrumb to all page, archive and search templates
*/
function hook_breadcrumb_to_pages_archive_search( $location ) {
if ( $location === 'archive' || $location == 'search' || $location == 'page' || $location == 'page-sidebar-left' || $location == 'page-sidebar-none') {
the_breadcrumb();
}
}
add_action( 'bootscore_after_primary_open', 'hook_breadcrumb_to_pages_archive_search'); Hook into breadcrumb to handle CPT’s
The breadcrumb system can be extended to support any custom post type by using the bootscore/breadcrumb/handler filter hook:
/**
* Add CPT handler
* Example https://github.com/bootscore/bootscore/blob/main/woocommerce/inc/wc-breadcrumb.php
*/
function my_cpt_breadcrumb_handler($handled) {
// Only handle our custom post type
if (is_singular('my_cpt')) {
// Your custom breadcrumb logic
return true; // Mark as handled
}
return $handled;
}
add_filter('bootscore/breadcrumb/handler', 'my_cpt_breadcrumb_handler', 15, 1);Shortcode
For maximum flexibility, Bootscore includes a [bs-breadcrumb] shortcode that displays breadcrumb navigation anywhere in your content. This is particularly useful for widget areas, custom page templates (like Page Blank), or any location where breadcrumbs can’t be added via standard action hooks. The shortcode automatically respects all the same conditional logic and formatting as the main breadcrumb function.
[bs-breadcrumb]Archive/Loop
Hide ‘Category:’ in archives but keep ‘Tag:/Month:/Author:’
/**
* Hide 'Category:' in archives but keep 'Tag:/Month:/Author:'
*
* add_filter( 'get_the_archive_title_prefix', '__return_empty_string' ); // Removes all
*/
add_filter( 'get_the_archive_title_prefix', function( $prefix ) {
if ( is_category() ) {
return '';
}
return $prefix; // Keep the default prefix for other archives like Tag and Month
});Show author Gravatar image if archive is author
/**
* Open a <div> in the 'bootscore_after_title' action on author archive pages
*/
function open_div_author_archive($location) {
if (is_author() && $location === 'archive') {
echo '<div class="d-flex mb-3">';
}
}
// Hook the function into 'bootscore_after_title'
add_action('bootscore_after_title', 'open_div_author_archive');
/**
* Add a function to display the author's Gravatar with a custom class in the 'bootscore_after_title' hook on author archive pages
*/
function my_author_gravatar_archive($location) {
// Check if we're on an author archive and if the location parameter matches 'archive'
if (is_author() && $location === 'archive') {
$author_id = get_queried_object_id(); // Get the author ID
echo '<div class="flex-shrink-0 me-3">';
echo get_avatar($author_id, 80, '', '', array('class' => 'img-thumbnail rounded-circle')); // Display Gravatar with a custom class
echo '</div>';
}
}
// Hook the function into 'bootscore_after_title'
add_action('bootscore_after_title', 'my_author_gravatar_archive');
/**
* Close the <div> in the 'bootscore_before_loop' action on author archive pages
*/
function close_div_author_archive($location) {
if (is_author() && $location === 'archive') {
echo '</div>';
}
}
// Hook the function into 'bootscore_before_loop'
add_action('bootscore_before_loop', 'close_div_author_archive');Vertical loop cards and read-more button
/**
* Hook the function to 'bootscore_before_loop'
*/
function hook_before_loop() {
echo '<div class="row">';
}
add_action( 'bootscore_before_loop', 'hook_before_loop' );
/**
* Hook the function to 'bootscore_before_loop_item'
*/
function hook_before_loop_item() {
echo '<div class="col-md-6 col-lg-4 mb-4">';
}
add_action( 'bootscore_before_loop_item', 'hook_before_loop_item' );
/**
* Hook the function to 'bootscore_after_loop_item'
*/
function hook_after_loop_item() {
echo '</div>';
}
add_action( 'bootscore_after_loop_item', 'hook_after_loop_item' );
/**
* Hook the function to 'bootscore_after_loop'
*/
function hook_after_loop() {
echo '</div>';
}
add_action( 'bootscore_after_loop', 'hook_after_loop' );
/**
* Change loop card class
*/
function loop_card_class() {
return "card border-0 shadow h-100";
}
add_filter('bootscore/class/loop/card', 'loop_card_class', 10, 2);
/**
* Change loop card row class
*/
function loop_card_row_class() {
return "d-flex flex-column h-100";
}
add_filter('bootscore/class/loop/card/row', 'loop_card_row_class', 10, 2);
/**
* Change loop image col class
*/
function loop_image_col_class() {
return "";
}
add_filter('bootscore/class/loop/card/image/col', 'loop_image_col_class', 10, 2);
/**
* Change loop content col class
*/
function loop_content_col_class() {
return "d-flex flex-column h-100";
}
add_filter('bootscore/class/loop/card/content/col', 'loop_content_col_class', 10, 2);
/**
* Change loop image class
*/
function loop_image_class() {
return "card-img-top";
}
add_filter('bootscore/class/loop/card/image', 'loop_image_class', 10, 2);
/**
* Change loop card-body class
*/
function loop_card_body_class() {
return "card-body h-100 d-flex flex-column";
}
add_filter('bootscore/class/loop/card/body', 'loop_card_body_class', 10, 2);
/**
* Change loop excerpt card-text class
*/
function loop_card_text_excerpt_class() {
return "card-text small";
}
add_filter('bootscore/class/loop/card-text/excerpt', 'loop_card_text_excerpt_class', 10, 2);
/**
* Change loop read-more card-text class
*/
function loop_card_text_read_more_class() {
return "card-text mt-auto";
}
add_filter('bootscore/class/loop/card-text/read-more', 'loop_card_text_read_more_class', 10, 2);
/**
* Change loop read-more class
*/
function loop_read_more_class() {
return "btn btn-primary d-block";
}
add_filter('bootscore/class/loop/read-more', 'loop_read_more_class', 10, 2);
/**
* Change loop read-more text
*/
function change_loop_read_more_text($title) {
return 'Continue reading <i class="fa-solid fa-arrow-right"></i>';
}
add_filter('bootscore/loop/read-more/text', 'change_loop_read_more_text');Contents
Spacer
Change entire spacers:
/**
* Change all content spacers
*/
function change_content_spacer($spacer) {
return 'my-5 p-5';
}
add_filter('bootscore/class/content/spacer', 'change_content_spacer');Change spacer on an single file:
/**
* Change content spacer on an archive page of the post type "product"
*/
function change_content_spacer($spacer) {
if (is_post_type_archive('product')) {
return 'my-5 p-5';
}
return $spacer;
}
add_filter('bootscore/class/content/spacer', 'change_content_spacer');Hide meta post updated time
/**
* Hide meta post updated time
*/
function disable_updated_time_display($show_updated_time) {
return false;
}
add_filter('bootscore/meta/time/updated', 'disable_updated_time_display');Hide meta post author
/**
* Hide meta post author
*/
function hide_author_function($display_author) {
return false;
}
add_filter('bootscore/meta/author', 'hide_author_function');Main col, sidebar and breakpoints
/**
* Change main content col
*/
function change_content_col_size($col_size) {
if (is_active_sidebar('sidebar-1')) {
return "col-md-9 col-lg-8 col-xl-9";
}
return $col_size;
}
add_filter('bootscore/class/main/col', 'change_content_col_size', 11);
/**
* Change sidebar col
*/
function change_sidebar_col_size($col_size) {
return "col-md-3 col-lg-4 col-xl-3 order-first order-md-2";
}
add_filter('bootscore/class/sidebar/col', 'change_sidebar_col_size');
/**
* Change sidebar responsive offcanvas
*/
function change_sidebar_offcanvas($col_size) {
return "offcanvas-md offcanvas-start";
}
add_filter('bootscore/class/sidebar/offcanvas', 'change_sidebar_offcanvas');
/**
* Change sidebar toggler button breakpoint and class
*/
function change_sidebar_toggler($col_size) {
return "d-md-none btn btn-light w-100 mb-4 d-flex justify-content-between align-items-center";
}
add_filter('bootscore/class/sidebar/button', 'change_sidebar_toggler');Category badge
/**
* Change category badge class
*/
function change_category_badge_link_class($class) {
return 'badge bg-warning-subtle border border-warning-subtle text-warning-emphasis rounded-pill text-decoration-none';
}
add_filter('bootscore/class/badge/category', 'change_category_badge_link_class');Tag badge
/**
* Change tags badge class
*/
function change_tag_link_class($class) {
return 'badge bg-danger-subtle border border-danger-subtle text-danger-emphasis rounded-pill text-decoration-none';
}
add_filter('bootscore/class/badge/tag', 'change_tag_link_class');/**
* Remove tag icon
*/
add_filter('bootscore/show/tag/icon', '__return_false');Comments
Closed comments alert class
/**
* Closed comments alert class
*/
function change_comments_closed_alert_class() {
return "alert alert-warning alert-icon alert-warning-icon";
}
add_filter('bootscore/class/comments/closed/alert', 'change_comments_closed_alert_class', 10, 2);Closed comments alert content
/**
* Closed comments alert text
*/
function change_comments_closed_text($text) {
return 'Comments are closed. Please join the <a target="_blank" class="alert-link" href="https://github.com/orgs/bootscore/discussions">Discussions forum</a> on GitHub.';
}
add_filter('bootscore/comments/closed/text', 'change_comments_closed_text');Blocks
Widget search button
/**
* Change searchform block widget button class
*/
function change_block_widget_search_button_class($class) {
return 'btn btn-outline-danger';
}
add_filter('bootscore/class/widget/search/button', 'change_block_widget_search_button_class');Widget categories badge
/**
* Change widget categories badge
*/
function change_block_widget_categories_badge($block_content, $block) {
$search = array(
'<span class="badge bg-primary-subtle text-primary-emphasis">'
);
$replace = array(
'<span class="badge bg-danger rounded-pill">'
);
return str_replace($search, $replace, $block_content);
}
add_filter('bootscore/block/categories/content', 'change_block_widget_categories_badge', 10, 2);Table
/**
* Change table block classes
*/
function block_table_class() {
return "table-bordered table-striped table-hover";
}
add_filter('bootscore/class/block/table', 'block_table_class', 10, 2);Footer
Footer Top
/**
* Footer top classes
*/
function footer_top_class() {
return "bg-success text-white border-top border-secondary pt-5 pb-4";
}
add_filter('bootscore/class/footer/top', 'footer_top_class', 10, 2);Footer 1-4 wrapper
/**
* Change footer column wrapper classes
*/
function footer_class() {
return "bg-dark text-white border-top border-secondary pt-5 pb-3";
}
add_filter('bootscore/class/footer/columns', 'footer_class', 10, 2);Footer 1-4 columns
Change all footer columns:
/**
* Change footer 1-4 col
*/
function footer_col_class() {
return "col-12 col-md-6 col-lg-3";
}
add_filter('bootscore/class/footer/col', 'footer_col_class', 10, 2);Change each footer-column:
/**
* Change footer 1 col
*/
function footer_col_1_class($string, $location) {
if ($location == 'footer-1') {
return "col-6 col-md-12 col-lg-6";
}
return $string;
}
add_filter('bootscore/class/footer/col', 'footer_col_1_class', 10, 2);
/**
* Change footer 2, 3, 4 col
*/
function footer_col_2_3_4_class($string, $location) {
if ($location == 'footer-2' || $location == 'footer-3' || $location == 'footer-4') {
return "col-6 col-md-4 col-lg-2";
}
return $string;
}
add_filter('bootscore/class/footer/col', 'footer_col_2_3_4_class', 10, 2);Footer info
/**
* Change footer info classes
*/
function footer_info_class() {
return "bg-dark text-white border-top border-secondary py-2 small";
}
add_filter('bootscore/class/footer/info', 'footer_info_class', 10, 2);To-top button
/**
* Change to-top button classes
*/
function footer_to_top_button_class() {
return "btn btn-light shadow-lg";
}
add_filter('bootscore/class/footer/to_top_button', 'footer_to_top_button_class', 10, 2);WooCommerce
Grid columns
/**
* Change WooCommerce column class
*/
function change_woo_columns($class) {
return 'col-6 col-lg-4';
}
add_filter('bootscore/class/woocommerce/col', 'change_woo_columns');Sidebar to left
/**
* Move WooCommerce content to right (Sidebar left)
*/
function move_wc_content_col_to_end($col_size) {
if (is_woocommerce() && is_active_sidebar('sidebar-1')) {
return "col-lg-9 order-lg-last";
}
return $col_size;
}
add_filter('bootscore/class/main/col', 'move_wc_content_col_to_end', 11);Reviews tab badge
/**
* Change WC reviews tab badge
*/
function change_wc_reviews_tabs_badge() {
return '<span class="badge text-bg-danger">%s</span>';
}
add_filter('bootscore/class/reviews/tab-badge', 'change_wc_reviews_tabs_badge', 10, 2);Loop out-of-stock badge class
/**
* Change WC loop out-of-stock badge class
*/
function change_wc_loop_out_of_stock_badge() {
return 'badge bg-warning text-wrap mt-2 mb-0';
}
add_filter('bootscore/class/woocommerce/loop/out-of-stock-badge', 'change_wc_loop_out_of_stock_badge', 10, 2);Disable loop out-of-stock badge
/**
* Disable loop out-of-stock badge
*/
add_filter('bootscore/woocommerce/loop/show-out-of-stock-badge', '__return_false');Disable Read more button if product is out of stock
/**
* Disable Read more button if product is out of stock
*/
add_filter('bootscore/woocommerce/loop/out-of-stock-remove-read-more', '__return_true');Disable scripts
Font Awesome
/**
* Disable Font Awesome
*/
add_filter('bootscore/load_fontawesome', '__return_false');AJAX cart
/**
* Disable AJAX cart
*/
add_filter('bootscore/load_ajax_cart', '__return_false');AJAX login
/*
* Disable AJAX login
*/
add_filter('bootscore/wc_ajax_login', '__return_false');scssphp compiler
/**
* Disable scssphp compiler
*/
add_filter('bootscore/scss/disable_compiler', '__return_true');Unsupported blocks and patterns
/**
* Disable unsupported blocks and patterns
*/
add_filter('bootscore/disable/unsupported/blocks', '__return_true');