Site logo

Archived topic

Site Title in Navigation Bar

9 replies · Started by Gary on August 13, 2017

Viewing posts 1–10 of 10

How can I get the site title to appear in the primary navigation bar (at the left) on every page but the home page?

Thanks!
Gary

You can try this php

//Site title inside navigation
add_action( 'generate_inside_navigation','site_title_inside_navigation' );
function site_title_inside_navigation() { 
  if ( !is_front_page() ){?>
    <div class="inside-navigation-content">
        <a href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></a>
    </div>
	<?php }
  }

Then add this css

.inside-navigation-content {
    display: inline-block;
    float: left;
    padding-top: 10px;
}

Adding PHP: https://docs.generatepress.com/article/adding-php/
Adding CSS: https://docs.generatepress.com/article/adding-css/

Thanks Jamal!

Happy to help out Leo. I had this ready in my GeneratePress gist so i copy pasted it here.

I copied both pieces of code provided into 'Code Snippets' and 'Simple CSS'.
I do not see the site title in the menu.
On pages other than the front page, the last menu item wraps onto the next line (which I do not want to happen).

I have removed it from my site for now as its not working.

Was I supposed to modify any of the code to meet my specific site?

Thanks!
Gary

The first block of code goes into Code Snippet and url need to be replaced with the actual site url.

The second block og code goes into Simple CSS and nothing needs to be modified there.

If this doesn't work can you link me to the site?

Thanks!

I want to add the site-description to the navigation along with the site-title too. What should this code look like in order to do that? Thanks in advance.

Hi Paul, something like this:

add_action( 'generate_inside_navigation','site_title_inside_navigation' );
function site_title_inside_navigation() { ?>
    <div class="inside-navigation-content">
        <a href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></a>
        <p title="<?php bloginfo('description'); ?>"><?php bloginfo('description'); ?></a>
        </div>
<?php }

Cheers, thanks David!

Glad to be of help

This archived topic is closed to new replies.