Site logo

Archived topic

Colored site title

1 reply · Started by Maurizio Grassi on August 16, 2022

Viewing posts 1–2 of 2

My site title (and my company) are zero2stars.
I would like to style my site title with different colors, for example something like
zero(blue)2(black)stars(dark red) using the same colors of the logo.
I know that one option is to embed this in the logo pict.
Is there any other way ?

Hi there,

you would need a PHP Snippet so we can add the extra HTML that would require.

add_filter( 'generate_site_title_output', function( $output ) {
    $titleHTML = 'zero<span class="accent-one">2</span><span class="accent-two">stars</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
    );
});

Adding PHP:

https://docs.generatepress.com/article/adding-php/

Then you can add the extra colors with CSS:

.main-title .accent-one {
    color: black;
}
.main-title .accent-two {
    color: red;
}
This archived topic is closed to new replies.