The following actions and filters can be used in the functions.php file of your myBREW child theme to customize your BREW. These hooks are recommended for advanced users who are comfortable modifying PHP files. It’s always a good idea to back up your website before editing theme files.


Hide Post Dates

This filter can be used to hide the post publish date by returning false. This removes the date from the source code, as opposed to just changing the visibility of the date via CSS. Note that this does not prevent Schema markup plugins from including the publish date in its output.

Example To Hide Post Date

add_filter( 'brew_display_post_date', '__return_false' );

Custom Archive Titles

This WordPress filter can be used to customize the h1 titles of archive pages such as the Team archive or Showcase archive. Make sure to target only the relevant post types to avoid changing the titles of unintended pages.

The page title as displayed at the top of the browser window can be edited using the Yoast SEO plugin.

Example To Change The “Our Team” Title

function mybrew_custom_archive_titles( $title ) {

	if ( is_post_type_archive( 'brew_team' ) ) {
		$title = 'Why Choose Us';
	}

	return $title;

}
add_filter( 'get_the_archive_title', 'mybrew_custom_archive_titles', 20, 1);

Rounded Edges

Use this filter to activate rounded edges throughout your website without adding custom CSS.

Example To Activate Rounded Edges

add_filter( 'brew_border_radius', '__return_true' );

Control Sidebar Display

Use this filter to control what types of pages will display the sidebar. Use WordPress conditional tags as needed. Make sure your function passes $display through as an argument and returns it, otherwise you’ll get unexpected results. Note the BREW front page is not currently compatible with the sidebar.

Example To Hide Sidebar On All Blog Posts

function mybrew_display_sidebar( $display ) {

	if ( is_singular( 'post' ) ) {
		$display = false;
	}

	return $display;

}
add_filter( 'brew_display_sidebar', 'mybrew_display_sidebar' );

Example To Show Sidebar On Main Blog Page (Page For Posts)

function mybrew_display_sidebar( $display ) {

	if ( is_home() ) {
		$display = true;
	}

	return $display;

}
add_filter( 'brew_display_sidebar', 'mybrew_display_sidebar' );

TOC+ Table on Blog Posts

Use this filter to toggle whether or not TOC+ plugin tables will be allowed on posts that use BREW content blocks. This filter assumes you’ve configured the TOC+ plugin to automatically add tables of content to your posts.

Example To Allow TOC+ Tables

add_filter( 'brew_hide_plugin_toc', '__return_false' );

Top of Body Content

Use this action to add code to the very top of the HTML <body> element, just below the opening <body> tag. This is useful for certain Google Tag manager codes.

Example to Add Google Tag Manager Code

function mybrew_body_top() { ?>
  [Your Custom HTML Code Here]
  <?php
}
add_action( 'brew_body_top', 'mybrew_body_top' );

Showcase Category Box Prefix

Use this filter to globally change (or remove) the text that comes before the category box heading. By default, the text is “Browse By”. This filter will be ignored by any category box that is using the “Category Tab / Heading Text” field.

Example to Remove the Default “Browse By” Text

add_filter( 'brew_category_box_prefix', function() { return ''; } );

Example to Change the Default Text to “Shop By”

add_filter( 'brew_category_box_prefix', function() { return 'Shop By'; } );

Disable Blog Content Block Editor

Use this filter to globally remove the content block interface when adding and editing blog posts. IMPORTANT: When you turn off content block editing, any changes you make to the content of the blog post will only appear in the default WordPress editor and will not be present in the content block editor if you later turn the content block editor back on.

Example to Remove the Content Block Editor from Blog Posts

add_filter( 'brew_use_blog_builder', '__return_false' );

Header Content

This filter allows you to choose what content is displayed on the right side of the header (or below the logo and mobile menu button on small screens). Choices include ‘topnav’ (default), ‘hero’, or ‘widget’.

If you choose ‘hero’, you should remove the Hero Element block from your home page display settings. If you choose ‘hero’ or ‘widget’, you must use the ‘brew_solo_nav’ filter to display the primary navigation below the header.

Example To Display The Hero Element in Header

add_filter( 'brew_header_content', function() { return 'hero'; } );

Sticky Header

This filter allows you to activate a sticky header by returning true. The header will stick to the top of the web browser on screens larger than 991px.

Sticky Header is not recommended for use when brew_header_content filter is set to hero or widget.

Example To Display A Sticky Header

add_filter( 'brew_sticky_header', '__return_true' );

Primary Navigation Below Header

This filter should be used when ‘brew_header_content’ filter has been set to ‘hero’ or ‘widget’ so that the primary navigation is displayed below the entire header element. This filter results in the primary navigation taking up the full width of the website template instead of sharing space with the site logo on large screens.

Example To Display Navigation Below Header

add_filter( 'brew_solo_nav', '__return_true' );

Mobile Menu Button Location

This filter can be used to change the location of the primary navigation’s mobile menu button. This filter is best used in combination with ‘brew_solo_nav’ filter. Choices include ‘header’ (default) or ‘nav’.

Example To Display Mobile Menu Button Below Header

add_filter( 'brew_topnav_button_location', function() { return 'nav'; } );

Custom HTML Attributes

This filter allows you to customize the value of certain HTML attributes to achieve different layouts and designs without the need to duplicate parent theme files in your child theme. The function that you pass to the filter should return an array of custom values.

Available Attributes with Default Settings

 

Element HTML Attribute Default Description
brew_fp_agent_column_1 class col-sm-4 col-sm-push-8 This class is applied to the first column of the Agent content block on the home page.
brew_fp_agent_column_2 class col-sm-8 col-sm-pull-4 This class is applied to the second column of the Agent content block on the home page.
brew_fp_c2a_column_1 class col-md-5 col-md-offset-7 This class is applied to the Call to Action content block column on the home page.
brew_fp_icon_box_columns class This can be used to override the default column class for the home page featured icon boxes.
brew_header_column_1 class col-xs-6 col-sm-3 This class is applied to the header column that contains the site logo.
brew_header_column_2 class col-xs-6 visible-xs-block This class is applied to the header column that contains the mobile nav menu button.
brew_header_column_3 class col-xs-12 col-sm-9 This class is applied to the header column that contains primary navigation.
brew_feature_row_default class feature-row-secondary This class is applied to odd numbered home page rows. The default class uses the theme’s Secondary Color choice from Customizer.
brew_topbar_column_1 class col-xs-6 This class is applied to the first column (left side) of the top bar, above the header.
brew_topbar_column_2 class col-xs-6 This class is applied to the second column (right side) of the top bar, above the header.
brew_topbar_social_icons target _blank Set this to “_blank” to have the default top bar social links open in a new window. Set this to “_self” or leave it empty “” to open the links in the same window.
brew_team_social_icons target _blank Set this to “_blank” to have the Team social links open in a new window. Set this to “_self” or leave it empty “” to open the links in the same window.

Example To Customize The Size Of Header Columns For Small, Square Logos
This results in a smaller space for the logo and larger space for other header content (navigation, hero, or header widget).

function mybrew_custom_attr() {

  $attributes['brew_header_column_1']['class'] = 'col-xs-6 col-sm-2';
  $attributes['brew_header_column_3']['class'] = 'col-xs-12 col-sm-10';
  
  return $attributes;

}
add_filter( 'brew_custom_attr', 'mybrew_custom_attr' );

Unhide Cities and Communities Admin Link

The Cities and Communities post types are deprecated, so the admin links to these sections have been hidden as of BREW Companion 1.21.0. For older sites that still have content in these sections, you can unhide the admin links with the following filter examples.

Unhide Cities Admin Links

/**
 * Show the BREW Companion 'Cities' custom post type menu in admin.
 */
function mybrew_show_cities_cpt( $args, $post_type ){

    if ( $post_type == 'brew_cities' ){

        $args['show_in_menu'] = true;

    }

    return $args;
}
add_filter( 'register_post_type_args', 'mybrew_show_cities_cpt', 10, 2 );

Unhide Communities Admin Links

/**
 * Show the BREW Companion 'Communities' custom post type menu in admin.
 */
function mybrew_show_communities_cpt( $args, $post_type ){

    if ( $post_type == 'brew_communities' ){

        $args['show_in_menu'] = true;

    }

    return $args;
}
add_filter( 'register_post_type_args', 'mybrew_show_communities_cpt', 10, 2 );