Archived topic
site-title link goes to '/wp' instead of '/'
3 replies · Started by Neil on February 3, 2021
WordPress Address (URL) = /wp
Site address = /
I added the site title to navigation following this article: https://docs.generatepress.com/article/add-site-title-to-navigation/
Works great, but now my site-title link goes to /wp instead of /.
The url of the staging site is: https://evafogelman.earthstage.pw/
It is the main-title. Do I bring header.php into my child theme? Not sure what to do.
It does the same thing locally.
Hi there,
Can you try this instead?
add_action( 'after_setup_theme', 'tu_navigation_as_header' );
function tu_navigation_as_header() {
remove_action( 'generate_header', 'generate_construct_header' );
add_action( 'generate_inside_navigation', 'tu_site_title_navigation' );
}
function tu_site_title_navigation() {
?>
<div class="site-branding">
<p class="main-title" itemprop="headline">
<a href="<?php echo home_url('/'); ?>" rel="home">
<?php bloginfo( 'name' ); ?>
</a>
</p>
</div>
<?php
}
We simply changed site_url(); to home_url('/');.
site_url() takes the path you've added on WordPress Address (URL) while home_url() takes the Site address (URL) set in your General Settings.
Thanks Elvin! That worked.
Nice one. Glad it worked for you. No problem. :)