Site logo

Archived topic

Main-title in 2 colors or some bold letters

1 reply · Started by Diego on December 12, 2020

Viewing posts 1–2 of 2

Hi,

I wondered if it is possible, through CSS code, to put the title in two colors or some bold letters.

I have tried adding tags to the title but have not succeeded so far.

https://fluentspanish.express

Thank you.

Hi there,

you would need a PHP Snippet to do that:

add_filter( 'generate_site_title_output', function( $output ) {
    $titleHTML = 'My title <span class="custom-style">with custom style</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
    );
});

Simply update the $titleHTML variable with your site title text and custom CSS Class.

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

Reference doc:
https://docs.generatepress.com/article/generate_site_title_output/

This archived topic is closed to new replies.