Site logo

Archived topic

Site Title in two lines using Navigation as Header

16 replies · Started by ANGELA on December 10, 2022

Viewing posts 1–15 of 17

Hi,
I am using the "Aroma" template from the GeneratePress site library, which uses the navigation as a header. Because my site title is too long, I would like to display it in two lines. Could you please tell me how I can make it possible?
Thanks so much for your help
Angela

Hi there,

so the Site Title field in WP customizer won't support HTML or line breaks.
You will need to use a PHP Snippet like this:


add_filter( 'generate_site_title_output', function( $output ) {
    $titleHTML = '<span class="line-one">Line one</span><span class="line-two">line two</span>';
    return sprintf(
        '<%1$s class="main-title" itemprop="headline">
	<a href="%2$s">%3$s</a>
	</%1$s>',
	( is_front_page() && is_home() ) ? 'h1' : 'p',
	esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
	$titleHTML
    );
});

On this line : $titleHTML = '<span class="line-one">Line one</span><span class="line-two">line two</span>';
You need to change the text between the span tags for your title.

How to add PHP: https://docs.generatepress.com/article/adding-php/

Then add a little CSS to stack them:


.main-title span {
    display: block;
}

Thanks so much; I will try to do it!

Hi David,
I added the snippet and the CSS code, but unfortunately, it is not working.
Thanks

Can i see the site ?

Hi Angela,

That's odd. May we know how you specifically added the PHP snippet?

I see. Viewing your screenshot, it's showing that the Snippet is currently not activated. Can you activate it first?

Oh, I see...
I just activated it!

Great! Let us know how it goes.

I see. Can you update the CSS code provided previously to this one?:

.main-title span {
    display: block;
    line-height: 1.2;
    text-align:center;
}

Let us know how it goes.

Yes, it's possible.

Can you try adding this CSS?:

.inside-navigation .navigation-branding {
    justify-content: center;
}

Let us know how it goes.

This archived topic is closed to new replies.