Site logo

Archived topic

site title

4 replies · Started by Nikolaj on September 13, 2020

Viewing posts 1–5 of 5

when using site title it seems like there's added a space to the code so that 'smv' in the title appears as 'smv ' with extra space in the code;

This is a problem when I'm adding extra text with a css ::before to the title; It want the following result: smvBrobygger. However it ends up smv brobygger

http://www.smvbrobygger.dk

code:
.main-title a::before {
content: "smv";
}

How to get rid of the extra space or even better how to add formating to the first 3 letters in the title?

Instead of using a pseudo selector, I would filter the output of the site title:

add_filter( 'generate_site_title_output', function() {
    return sprintf(
        '<%1$s class="main-title" itemprop="headline">
            <a href="%2$s" rel="home">
                <span class="title-prepend">smv</span>%3$s
            </a>
            </%1$s>',
            ( is_front_page() && is_home() ) ? 'h1' : 'p',
            esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
            get_bloginfo( 'name' )
    );
} );

Then you can format it like this:

.title-prepend {
    /* whatever */
}

Thanks - but actually my challenge is that I want the site tile to be: smvbrobygger where smv is added a class to make it bold and yellow; Like <span class="something">smv</span>brobygger

How would that be possible? I can't see how it should work with the code you sent?

sorry it worked - thanks...

You're welcome :)

This archived topic is closed to new replies.