Black Friday sale! Get up to 25% off GP Premium! Learn more ➝

[Resolved] Dynamic Site Header and Page Titles

Home Forums Support [Resolved] Dynamic Site Header and Page Titles

Home Forums Support Dynamic Site Header and Page Titles

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #394035
    Louis

    Hi everyone,

    I’m trying to do something fairly simple. At least I think I am, but I’m running into some issues.

    My goal is to have my main navigation bar below my header on just one page. This works fine -in theory- if I use the site header for it.

    However, I want to have my navigation bars at the top on all other pages and posts, so that the user can focus on the content rather than the massive site header that I created just for the front page.

    My problem is that I can’t seem to find a way to switch the position of the navigation bar without using the site header in the customiser, which in turn ruins my front page layout if I remove the site title and padding.

    Here’s a link to images that show what I’m talking about: https://imgur.com/a/X40st

    I’m showing my desired front page and how it affects the other pages.

    On a sidenote: I tried to add this code in simple CSS : `add_shortcode(
    ‘page_title’,’tu_page_title_shortcode’ );
    function tu_page_title_shortcode()
    {
    return get_the_title();
    }`

    and then use the page title shortcode in my page headers, but unfortunately it didn’t work.

    All help appreciated!

    #394230
    Leo
    Staff
    Customer Support
    #394661
    Louis

    I’ve now removed site title, tagline and all vertical padding, meaning the site header has become non existant. I’m using the Page headers to create my headers for every page.

    Also, the dynamic page titles work now that I’ve put the code into Code Snippets instead of Simple CSS! Makes sense heh.

    However, my main navigation bar has vanished from all my pages because I’m using this code with code snippets:

    add_filter( 'generate_navigation_location','tu_move_navigation' );
    function tu_move_navigation( $location )
    {
    	if ( is_home() ) {
    		return 'nav-below-header';
            }
    }

    My settings in the customizer have the nav bar located Above Header.

    Am I missing something?

    Second question: Is there a way for me to insert the site title and tagline when using Page Headers without using the site header merge toggle?

    The problem here is that if I enable Site Title and Tagline in the Customizer, they automatically appear as part of a site header, which again will create a sitewide header above my page header OR, if I merge them, the title and tagline will appear on ALL pages.

    Maybe there’s a way to add them to the page header specifically using the HTML container?

    Thanks in advance!

    #394842
    Leo
    Staff
    Customer Support

    – Try this instead:

    add_filter( 'generate_navigation_location','tu_move_navigation' );
    function tu_move_navigation( $location )
    {
    	if ( is_home() ) {
    		return 'nav-below-header';
            }
    
            return $location;
    }

    Also just to make sure that is_home() is targeting the main blog page.

    – Not sure what you mean? Where do you want to insert it? Can you link me to the page?

    #395142
    Louis

    Nevermind the text. It’s not that important, I’ll make it work.

    The new code made my navigation bar show up, but didn’t put it below my header. I switched is_home() for is_front_page() and it did the trick.

    However, the problem now is that my navigation bar is still only below the site header, not the page header. Is there a way for me to fix this?

    I tried looking at sections to see if I could just make a section to serve as my navigation bar, but couldn’t find an easy way to do it.

    #395373
    Leo
    Staff
    Customer Support
    #397361
    Louis

    That did the trick!

    Thanks a ton!

    #397405
    Leo
    Staff
    Customer Support

    No problem!

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