[Support request] Colored site title

Home Forums Support [Support request] Colored site title

Home Forums Support Colored site title

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2314363
    Maurizio Grassi

    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 ?

    #2314432
    David
    Staff
    Customer Support

    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;
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.