godaddy-wordpress/primer

Change Logo URL

JClohessy opened this issue · 3 comments

Hi there,

Does anyone know where I can change the url of the logo in this theme? I can't find the code anywhere!

Thanks,

James

Hi @Eldorado-Jacobin ,

Are you trying to change the image itself, or are you trying to change where the image links to?

If you are attempting to update the URL to where the image is pointing to (eg: The end location when the site logo is clicked), then you can use the following code snippet and define your own custom URL.

/**
 * Filter the custom logo, and add a custom URL.
 *
 * @return string       Custom site logo markup.
 */
function primer_custom_logo_url() {

	return sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
		esc_url( 'https://www.google.com' ),
		wp_get_attachment_image( get_theme_mod( 'custom_logo' ), 'full', false, array(
			'class' => 'custom-logo',
		) )
	);

}
add_filter( 'get_custom_logo', 'primer_custom_logo_url' );

What you'll want to do is add that to a custom MU plugin and add the above code snippet to it. We have some documentation setup on how to create a custom MU plugin for your site: https://godaddy.github.io/wp-primer-theme/tutorials-and-examples/tutorials/mu-plugin.html

Evan

Issue should be resolved with the above code as per the WordPress.org support thread: https://wordpress.org/support/topic/change-href-of-the-logo/