Site logo

Archived topic

Change Main-Title (within header) Without Changing Site-Title

16 replies · Started by Toby on January 13, 2020

Viewing posts 1–15 of 17

Hey support,

Is it possible to change the main-title text that appears within the header without adjusting the site-title?

A workaround would be a using an image as the logo but I like the styling of the default text that comes with the Arctic theme.

This change would be site wide.

Thanks,

Toby

Hi there,

can you provide a link to your site so i can make sure i provide the correct advice.
You can edit your original topic and use the Site URL field to share the link privately.

URL added, thanks.

Create a new Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/

Add this HTML to the hook content - change the URL and branding text to suit:

<div class="navigation-branding">
    <p class="main-title" itemprop="headline">
	    <a href="https://home_url" rel="home">Add your branding text here</a>
    </p>
</div>

Select the inside_navigation hook
And set Display Rules to entire site.

Then you can hide the Site Title in Customizer > Site Identity.

Thanks David, it almost looks great!

I've had a play around with the CSS but I can't get the header quite right.

The div is sitting above the navigation and not in-line to the left.

Is there a fix for this?

Thanks again!

It seems that when removing the site title, it removes some of the positioning.

It has also affected the display of the mobile menu.

I think that the issue is that when the site title is disabled, it removes the associated CSS to the inside-navigation class.

This disappears when the site-title is hidden:

#mobile-header .inside-navigation, .main-navigation.has-branding .inside-navigation, .main-navigation.has-sticky-branding.navigation-stick .inside-navigation {
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

Hi there,

Instead of going the Element route, I would do this:

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

That way you can keep the Site Title option active.

Worked a treat, thanks Tom/David!

Glad we could help! :)

Hi there.
Is it possible to do something like this with the tagline too?

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

Thanks.

Yes, there's a generate_site_description_output filter as well:

add_filter( 'generate_site_description_output', function() {
    return sprintf(
        '<p class="site-description"%s>
            Your custom tagline
        </p>',
        'microdata' === generate_get_schema_type() ? ' itemprop="description"' : ''
    );
} );

Brilliant. Thank you.

Not sure why but this generates errors.

add_filter( 'generate_site_description_output', function() {
    return sprintf(
        '<p class="site-description"%s>
            Your custom tagline
        </p>',
        'microdata' === generate_get_schema_type() ? ' itemprop="description"' : ''
    );
} );

Your PHP code changes were rolled back due to an error on line 48 of file wp-content/themes/WoldsWildlife/functions.php. Please fix and try saving again.
Uncaught Error: Call to undefined function generate_get_schema_type() in wp-content/themes/WoldsWildlife/functions.php:48
Stack trace:
#0 wp-includes/class-wp-hook.php(287): {closure}('<p class="site-...')
#1 wp-includes/plugin.php(206): WP_Hook->apply_filters('<p class="site-...', Array)
#2 wp-content/themes/generatepress/inc/structure/header.php(194): apply_filters('generate_site_d...', '<p class="site-...')
#3 wp-content/themes/generatepress/inc/structure/header.php(71): generate_construct_site_title()
#4 wp-content/themes/generatepress/inc/structure/header.php(32): generate_header_items()
#5 wp-includes/class-wp-hook.php(287): generate_construct_he

Line 48 is the line mentioning microdata.

Make sure you're using GeneratePress 3.0 :)

This archived topic is closed to new replies.