- This topic has 3 replies, 2 voices, and was last updated 3 years, 3 months ago by
David.
-
AuthorPosts
-
February 10, 2023 at 11:55 am #2528833
Dan
Hi, I’m using these 2 filters to change the logo’s link, title and alt.
Is there a more efficient way to do this?
Alswo I see that the href ads a bunch of string to it, can those be removed?add_filter( 'generate_logo_output','tu_logo_atts', 10, 2 ); function tu_logo_atts( $output, $logo ) { printf( '<div class="site-logo"> <a href="%1$s" title="my title" rel="home"> <img class="header-image is-logo-image" src="%3$s" alt="Back to site" title=" site home" /> </a> </div>', esc_url( apply_filters( 'generate_logo_href' , home_url( '/' )) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), esc_url( apply_filters( 'generate_logo', $logo ) ) ); } add_filter( 'generate_logo_href','generate_custom_logo_href' ); function generate_custom_logo_href() { // Enter the URL you want your logo to link to below return 'https://mysite.com'; }The a href url looks like this:
<a href="https://mysite.com/?__hstc=51647990.cc4469c32bee7a80da4ef82ecea1f255.1641495277475.1668706996969.1670949202315.31&__hssc=51647990.12.1676054050313&__hsfp=901111203" title="" rel="home">
not sure where those characters are coming from. They show up only when filtering the logo href url.Thanks!
DanFebruary 11, 2023 at 5:57 am #2529347David
StaffCustomer SupportHi there,
you can do it just with the
generate_logo_outputfilter:add_filter( 'generate_logo_output','tu_logo_atts', 10, 2 ); function tu_logo_atts( $output, $logo ) { printf( '<div class="site-logo"> <a href="%1$s" title="my title" rel="home"> <img class="header-image is-logo-image" src="%3$s" alt="Back to site" title=" site home" /> </a> </div>', esc_url( apply_filters( 'generate_logo_href' , 'your_link_url_goes_here' ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), esc_url( apply_filters( 'generate_logo', $logo ) ) ); }Note that the change is to this line:
esc_url( apply_filters( 'generate_logo_href' , 'your_link_url_goes_here' ) ),February 11, 2023 at 7:38 am #2529420Dan
Thanks David!
That works.Have a nice weekend,
Dan
February 11, 2023 at 9:33 am #2529617David
StaffCustomer SupportYou’re welcome and you too!
-
AuthorPosts
- You must be logged in to reply to this topic.