[Resolved] Change Main-Title (within header) Without Changing Site-Title

Home Forums Support [Resolved] Change Main-Title (within header) Without Changing Site-Title

Home Forums Support Change Main-Title (within header) Without Changing Site-Title

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #1131275
    Toby

    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

    #1131406
    David
    Staff
    Customer Support

    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.

    #1131409
    Toby

    URL added, thanks.

    #1131639
    David
    Staff
    Customer Support

    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.

    #1132084
    Toby

    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!

    #1132127
    Toby

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

    It has also affected the display of the mobile menu.

    #1132131
    Toby

    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;
    }
    #1132329
    Tom
    Lead Developer
    Lead Developer

    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.

    #1132382
    Toby

    Worked a treat, thanks Tom/David!

    #1133172
    Tom
    Lead Developer
    Lead Developer

    Glad we could help! ๐Ÿ™‚

    #1476881
    Martin

    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.

    #1476989
    Tom
    Lead Developer
    Lead Developer

    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"' : ''
        );
    } );
    #1477842
    Martin

    Brilliant. Thank you.

    #1477862
    Martin

    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.

    #1477865
    Tom
    Lead Developer
    Lead Developer

    Make sure you’re using GeneratePress 3.0 ๐Ÿ™‚

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.