REIGN

11 min read · 2,133 words

How to Add 2 Lines of Text to a WordPress Header

How to add two lines of text to a WordPress header

The simplest way to get two lines of text in a WordPress header is to show the site title and the tagline stacked on top of each other. Set both under Settings, General, then display them in your header: with the Site Title and Site Tagline blocks in a block theme, or through the Site Identity panel in a classic theme. For custom wording, add a line break with Shift+Enter, or add a second line with a few lines of code in a child theme.

Which route you take depends on one question: does your theme use the Site Editor (a block theme) or the Customizer (a classic theme)? This guide covers both, plus CSS fixes for when the two lines refuse to stack.

First, find out which kind of theme you use

Open Appearance in your dashboard.

  • If you see Editor, you run a block theme. Your header is a template part that you edit visually.
  • If you see Customize and Widgets or Menus, you run a classic theme. Your header comes from a PHP template and Customizer settings.

Some classic themes, and some themes that mix both, show extra header options in their own settings panel. Check there too before you write any code.

Why use two lines at all

A header with one line says who you are. A header with two lines also says what you do. Visitors decide in a few seconds whether a site is for them, and a short second line, such as “Online courses and a members community”, answers that without a banner or a paragraph.

  • Clarity. Name on top, purpose below.
  • Hierarchy. A larger first line and a smaller, lighter second line guide the eye.
  • Search results. Your tagline is also read by search engines and by tools that preview your link, so it should read well on its own.

Method 1: Block themes, using the Site Editor

This is the route to take if you have the Editor menu. You need no code.

  1. Go to Appearance, Editor. Open Patterns, then find the Header entry under Template parts. On older WordPress versions the Template parts item sits directly in the Editor menu.
  2. Click the pencil icon to edit the header.
  3. Select the Site Title block. Add a Site Tagline block under it. If your header uses a Row layout, wrap both blocks in a Group and choose the Stack layout so they sit vertically.
  4. Style each block in the sidebar: font size, weight, colour, spacing. Make the title larger and the tagline smaller.
  5. Click Save.

The Site Title and Site Tagline blocks read from Settings, General. Change the text there, not in the block. The block shows whatever you saved in those two fields, and a change applies everywhere the blocks appear.

Custom two-line text that is not your title and tagline

Sometimes you want wording that differs from your site title, such as an offer or a short slogan. Use a Group with two blocks inside it:

  1. Add a Group block to the header and set its layout to Stack.
  2. Inside it, add a Heading block for line one and a Paragraph block for line two.
  3. Type your text. Alternatively, put both lines in a single Paragraph block and press Shift+Enter between them. That inserts a line break (a <br>) instead of a new paragraph.

The two-block version is easier to style, because each line has its own font size and colour. The Shift+Enter version is better when the two lines belong together, such as an address.

A word on heading levels

Do not make the site title or tagline a Heading level 1 on every page. Many block themes set the Site Title block to a paragraph rather than a heading, so each page keeps one H1: its own title. You can check and change the level in the block toolbar. If you use a Heading block for a decorative line, choose a level that does not outrank your page content, or use a Paragraph block.

Method 2: Classic themes, using the Customizer

Most classic themes already print the site title and the tagline. If yours does, you are one setting away.

  1. Go to Appearance, Customize, then Site Identity.
  2. Fill in the Site Title and the Tagline.
  3. Tick the box that reads “Display Site Title and Tagline”. Some themes hide the tagline unless this box is on.
  4. Check the preview and click Publish.

If the tagline does not appear, your theme may not output it in the header, or it may hide it with CSS on small screens. Both are fixed below. You can also edit the same two fields under Settings, General, which gives the same result.

Method 3: Make the lines stack with CSS

If the title and tagline sit side by side, or the tagline is hidden, a small block of CSS usually fixes it. Add it under Appearance, Customize, Additional CSS. In a block theme, open the Site Editor, choose Styles, open the three dot menu and pick Additional CSS.

/* Classic themes: stack the title and tagline */
.site-branding {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.site-description {
	display: block;
	margin: 0;
	font-size: 0.875rem;
	opacity: 0.8;
}

The class names .site-branding, .site-title and .site-description are common, but each theme chooses its own. To check yours, right-click the header in your browser, choose Inspect, and read the class names on the title and tagline. Then use those in your CSS. For block themes the equivalent classes are .wp-block-site-title and .wp-block-site-tagline.

If the theme hides the tagline on mobile and you want it back, look for a rule like display: none on the tagline class inside a media query, and override it. Better still, decide deliberately: a long tagline on a narrow screen can push the menu button out of place. Check the result at phone width before you publish. Our guide to changing the background colour of your WordPress header uses the same inspect-and-override approach.

Method 4: A second line in a child theme

When your classic theme gives you no second line, add one in a child theme. Never edit the parent theme directly, because an update will erase your change. Create a child theme, copy the parent’s header.php into it, and find the code that prints the site title. Replace or extend it with this:

<div class="site-branding">
	<p class="site-title">
		<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
			<?php echo esc_html( get_bloginfo( 'name' ) ); ?>
		</a>
	</p>
	<p class="site-description">
		<?php echo esc_html( get_bloginfo( 'description' ) ); ?>
	</p>
</div>

This prints the title and tagline as two separate lines, with output escaped. Keep any extra classes or wrapper elements the parent theme uses, so its own CSS still applies.

Let site owners edit the second line

If the second line should differ from the tagline, add a Customizer field for it. Put this in the child theme’s functions.php:

add_action( 'customize_register', function ( WP_Customize_Manager $wp_customize ) {
	$wp_customize->add_setting(
		'header_line_two',
		array(
			'default'           => '',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);

	$wp_customize->add_control(
		'header_line_two',
		array(
			'label'   => __( 'Header second line', 'your-textdomain' ),
			'section' => 'title_tagline',
			'type'    => 'text',
		)
	);
} );

Then print it in header.php under the title:

<?php $line_two = get_theme_mod( 'header_line_two' ); ?>
<?php if ( $line_two ) : ?>
	<p class="header-line-two"><?php echo esc_html( $line_two ); ?></p>
<?php endif; ?>

The new field appears under Appearance, Customize, Site Identity. The value is sanitized when saved and escaped when printed, which is the standard pattern for any text a user can edit. Replace your-textdomain with your theme’s text domain so the label can be translated.

Use a plugin only if you cannot edit theme files. A code snippets plugin is a safer home for the customize_register function than the parent theme, but the header markup still needs to change in the template.

Method 5: A page builder header

Page builders can design a header from scratch. Elementor’s theme builder, which is a Pro feature, lets you create a header template under Templates, Theme Builder, then drag in a Site Title widget and a Site Tagline widget, or two text widgets of your own. Beaver Builder and Divi offer similar header builders. This gives you the most layout freedom, but it also adds a plugin that every page load depends on. If all you need is two lines of text, a block theme or a child theme is lighter and easier to maintain.

Design tips for two-line headers

  • Keep line two short. Aim for a phrase that fits on one line at phone width. If you need more words, it belongs in the page, not the header.
  • Create contrast. Use size and weight, not a second typeface. A bold title with a regular tagline looks cleaner than two competing fonts.
  • Check colour contrast. A light grey tagline on white looks refined and is hard to read. Aim for at least a 4.5 to 1 ratio between text and background, which is the WCAG standard for normal text.
  • Test sticky headers. A two-line header is taller. If your header sticks to the top, check that it does not cover too much of the screen on a phone.
  • Match your logo. If you use a logo image, the text lines may be redundant. Combine them only if the logo does not already say the same thing.
  • Do not use line breaks for spacing. Use CSS margin and gap instead, so the layout survives a font change.

Troubleshooting

  • The tagline does not show. Make sure the tagline field is not empty, that “Display Site Title and Tagline” is ticked, and that no CSS hides the tagline class.
  • Both lines appear on one line. Wrap them in a container with display: flex and flex-direction: column, or set the Group block to Stack.
  • My change vanishes after a theme update. You edited the parent theme. Move the edit to a child theme.
  • The Shift+Enter break shows on desktop but not on mobile. Check that your theme or an optimisation plugin is not stripping <br> tags from the header.
  • The header looks different after switching themes. Block theme template edits are saved per theme. Customizer settings and child theme code belong to the theme you used when you made them.

While you are in the header, it is worth reading how a theme can handle the rest of your layout. What are social and community networks gives context if your header is for a members site, where the menu, search and profile links compete with your two lines for space.

Frequently asked questions

How do I put two lines of text in my WordPress header?

Show the site title and the tagline stacked. In a block theme, add Site Title and Site Tagline blocks inside a Group set to Stack. In a classic theme, fill in both fields under Site Identity in the Customizer and make sure the tagline is displayed.

How do I add a line break in a WordPress header?

In the block editor, press Shift+Enter inside a Paragraph or Heading block to insert a line break. In template code, a <br> works, but two separate elements are easier to style and better for accessibility.

Where do I change the site title and tagline?

Go to Settings, General, and edit Site Title and Tagline. You can also edit them under Appearance, Customize, Site Identity in a classic theme. Both places save the same values.

Why does my tagline not appear in the header?

Your theme may not print it, or may hide it with CSS, often on small screens. Check that the tagline field is filled and displayed, then inspect the header in your browser to see whether a CSS rule hides it.

Do I need a plugin to do this?

No. Block themes handle it in the Site Editor, and classic themes handle it with the Customizer or a short child theme edit. A page builder is only needed if you want a fully custom header layout.

Will my header changes survive a theme update?

Block theme edits and Customizer settings are stored in your database and survive an update. Edits to a parent theme’s files do not, which is why code changes belong in a child theme.

Should the second line be an H1 or H2 heading?

Usually neither. The tagline is supporting text, so a Paragraph or the Site Tagline block is right. Each page should keep one H1, which is the page title.

Next step

A tidy header is one piece of a site people want to join. Reign is the WordPress theme for building a complete community site: social network, courses, member directory, marketplace and job board on one install. Try the live demos to see real headers on real layouts, or follow the community build guide to set up a full community site.

Reading
11 min · 2,133 words
Published
Sep 24, 2024
wbcomteam
Reign contributor

Writing about WordPress communities, BuddyPress, BuddyBoss, LMS plugins, and the business of paid communities.

Keep reading

More from the Reign blog

Browse all posts on community, WordPress, BuddyPress and the studio of plugins behind Reign.

What customers say on Trustpilot

Swift and expert coding!

Swift and expert coding by Kerit to apply a personalised display adjustment on the Reign Theme for a media plugin that was not fully supported at the moment.

RussellGB