Common changes with a few lines of code (Child theme recipes)
Also called: code snippets, functions.php recipes, child theme examples, customise with code, Reign hooks examples
Each recipe below makes one common change. Copy the snippet, paste it into your child theme, and save. Every snippet was tested on Reign 8.1.0 with the official child theme.
Before you start
Section titled “Before you start”- Install and activate the official child theme. See Build on Reign with a child theme.
- Open the child theme’s
functions.php. Paste each snippet at the very end, below the line that says “Your custom code goes below this line”. - Edit files through your host’s file manager or SFTP. If a snippet has a typo, the site can show an error. You can then fix the file the same way.
Try each change on a staging copy first if your site is busy.
Add a banner above the header
Section titled “Add a banner above the header”This puts a thin strip of text above your logo and menu, on every page. Use it for a sale, a notice or a phone number.
add_action( 'reign_before_masthead', function () { echo '<div class="my-top-banner">Free delivery on every order this week.</div>';} );Give it a colour in the child theme’s style.css.
.my-top-banner { padding: 6px 16px; text-align: center; background: var(--reign-site-button-bg-color); color: var(--reign-site-button-text-color);}The two var(--reign-site-button-...) colours are your button colours, so the banner follows your palette and dark mode.
You’ll know it worked when the strip shows above the header on every page.
Hide or change the page title area
Section titled “Hide or change the page title area”The page title area is the part under the header that shows the page name. It can sit inside the content or in a banner (the sub header).
Hide it on every normal page. The title stays in the page for screen readers and search engines.
add_filter( 'reign_title_context', function ( $context ) { if ( is_page() ) { $context['style'] = 'hidden'; } return $context;} );The style value can be content, banner or hidden. Check other screens with WordPress conditionals such as is_singular( 'post' ) or is_archive().
Change the words in the banner instead. This one renames category pages.
add_filter( 'reign_page_header_section_title', function ( $title ) { if ( is_category() ) { return 'Articles about ' . single_cat_title( '', false ); } return $title;} );You’ll know it worked when your pages show no visible title, or a category page reads “Articles about News”. The second snippet only shows when that screen uses the banner title style.
Change the excerpt length and the “read more” text
Section titled “Change the excerpt length and the “read more” text”On blog lists, Reign cuts each post to a short summary (an excerpt). This sets it to 12 words and changes the text at the end.
add_filter( 'reign_excerpt_length', function () { return 12;} );
add_filter( 'reign_excerpt_more', function () { return ' ... keep reading';} );These filters work while Customize > Blog > Advanced Excerpt is on, which is the default. The number in the snippet wins over the Excerpt Length setting.
You’ll know it worked when every post on the blog list stops after 12 words and ends with “… keep reading”.
Add a link to the member menu
Section titled “Add a link to the member menu”The member menu opens when a logged-in member clicks their photo in the header. This adds a “Help centre” link at the top of it. It needs BuddyPress or BuddyBoss.
add_action( 'reign_before_user_menu_item', function () { printf( '<li class="menu-item"><a href="/reign-family/reign/developer-guide/%s/"><span class="menu-title">%s</span></a></li>', esc_url( home_url( '/help/' ) ), esc_html__( 'Help centre', 'reign-child' ) );} );Use reign_after_user_menu_item to put the link at the bottom, after Log Out.
You’ll know it worked when “Help centre” is the first item in the member menu.
Load your own CSS file after Reign’s
Section titled “Load your own CSS file after Reign’s”The child theme’s style.css already loads after Reign. Use this when you want a separate file, for example css/my-site.css inside the child theme.
add_action( 'wp_enqueue_scripts', function () { wp_enqueue_style( 'my-site-extra', get_stylesheet_directory_uri() . '/css/my-site.css', array( 'reign_main_style' ), '1.0.0' );}, 6000 );The 6000 and the reign_main_style dependency make your file print after Reign’s main stylesheet. Your rules then win when they are equally specific. Raise the 1.0.0 version when you change the file, so browsers fetch the new copy.
You’ll know it worked when your file appears after reign_main_style-css in the page source.
Change one template part
Section titled “Change one template part”A template part is a small file that builds one piece of a page. This example changes the message on a search with no results.
-
Copy
reign-theme/template-parts/content-none.php. -
Paste it into your child theme at
reign-child-theme/template-parts/content-none.php. Create thetemplate-partsfolder if it is missing. -
In your copy, find this line.
esc_html__( 'No results for “%s”. Try a different keyword or check your spelling.', 'reign' ), -
Change it to your own words, with your child theme’s text domain.
esc_html__( 'We could not find “%s”. Try a shorter word, or browse our latest posts.', 'reign-child' ), -
Save the file.
You’ll know it worked when a search for a word that is not on the site shows your new message.
Keep the do_action() lines when you copy a template, so Reign and other plugins can still add to it. After a Reign update, compare your copy with the new original. See Override Reign templates for every folder.
Turn a Reign feature off
Section titled “Turn a Reign feature off”Many Reign features have an on/off filter. This one stops breadcrumbs (the “Home > Blog > Post” trail) on every screen, whatever the Customizer says.
add_filter( 'reign_show_breadcrumbs', '__return_false' );Other switches that work the same way:
| Filter | Return false to |
|---|---|
reign_search_federation |
Remove the plugin result sections from the search page |
reign_customize_classic_widgets |
Use block widgets in the Customizer again |
reign_alter_display_right_sidebar |
Leave the right sidebar out |
You’ll know it worked when no breadcrumb trail shows on any page.
Print Reign member or group cards in your own widget
Section titled “Print Reign member or group cards in your own widget”reign_bp_card_grid() (added in 8.1.1) prints the same cards the Members and Groups directories show, for a widget, shortcode or block that lists members or groups.
reign_bp_card_grid( 'members', array( 'query' => array( 'type' => 'newest', 'per_page' => 6 ), 'classes' => 'three',) );The first argument is members or groups. In $args, layout is one of the four directory layouts (for example wbtm-member-directory-type-2; the default is the layout set for your site), query is passed to bp_has_members() or bp_has_groups(), and classes adds classes to the list, such as a column count. It returns false and prints nothing on BuddyBoss, with a BuddyPress template pack other than Nouveau, or when the component is off. Check the result if you need a fallback.
To change the avatar size in the BuddyPress Members, Groups and Friends widgets in a widget area, set --reign-widget-avatar-size in your child theme’s CSS (default 44px).
:root { --reign-widget-avatar-size: 56px; }You’ll know it worked when the cards show where you called the function.
Remove the sidebar from blog posts
Section titled “Remove the sidebar from blog posts”This makes every single blog post full width, with no sidebar. Pages and the blog list keep their layout.
add_filter( 'reign_sidebar_layout', function ( $layout ) { if ( is_singular( 'post' ) ) { return 'full_width'; } return $layout;} );Other values are right_sidebar, left_sidebar, both_sidebar and stretched_view.
You’ll know it worked when a blog post fills the content width and shows no widgets beside it.
Add something before or after the footer
Section titled “Add something before or after the footer”These print a block just above the footer, or right below it, on every page.
add_action( 'reign_before_footer', function () { echo '<div class="my-before-footer">Join our newsletter.</div>';} );
add_action( 'reign_after_footer', function () { echo '<div class="my-after-footer">Site built by Example Studio.</div>';} );To change the copyright line itself, use the reign_footer_copyright_text filter. See Hooks reference.
You’ll know it worked when your two lines show above and below the footer.
Good to know
Section titled “Good to know”My snippet broke the site. What do I do?
Section titled “My snippet broke the site. What do I do?”Open functions.php again through your host’s file manager or SFTP. Remove the snippet you just added and save. The site comes back straight away.
Can I use a code snippets plugin instead?
Section titled “Can I use a code snippets plugin instead?”Yes. The PHP snippets work the same in a snippets plugin. The template part recipe needs the child theme, because it is a file.
Where do I find more hooks?
Section titled “Where do I find more hooks?”Every hook Reign offers is in the Hooks reference.

