- This topic has 17 replies, 3 voices, and was last updated 1 year, 8 months ago by David.
-
AuthorPosts
-
February 11, 2020 at 7:17 am #1161967johnaps
Hello, i have read all other support threads about this matter and non of the solutions written were of any help to my site…
I am trying to make my logo which is right next to the hamburger button, an h1 tag for seo purposes…
Its important though to not mess with any spacing of any element in any media, because everything is preconfigured and with no available space…Fore example i tried implementing 2 hooks one before site logo and one after with the first containing <h1> and the second </h1> respectively but no matter what css i tried my header spacings were messed up.
I think maybe with php code i ll be able to solve this, so if you can forward this directly to Tom, it would be very much appreciated!
But any suggestions are welcomed of course!~
February 11, 2020 at 7:37 am #1161994DavidStaffCustomer SupportHi there,
you can try this PHP snippet to add the H1 for the homepage only:
<?php add_filter( 'generate_logo_output', 'db_home_logo_htag', 10, 3 ); function db_home_logo_htag( $output, $logo_url, $html_attr ) { if ( is_front_page() ) { printf( '<div class="site-logo"> <h1> <a href="%1$s" title="%2$s" rel="home"> <img %3$s /> </a> </h1> </div>', esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), $html_attr ); } else { printf( '<div class="site-logo"> <a href="%1$s" title="%2$s" rel="home"> <img %3$s /> </a> </div>', esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), $html_attr ); } }
Then this CSS to remove the H1 styling:
.site-logo h1 { margin-bottom: 0 !important; line-height: unset; font-size: 0; }
February 11, 2020 at 8:41 am #1162081johnapsthank you very much! It worked! Is there any place in the code that i can manipulate whats my h1 “data” will be? Because i see in the code
”
a href=”%1$s” title=”%2$s” rel=”home”
”
or is that my logo’s div?Thank you very much!
February 11, 2020 at 10:47 am #1162186DavidStaffCustomer SupportWhat do you want it to be?
February 15, 2020 at 12:27 am #1165906johnapsΙ guess my site’s name with the city my physical store is in, which also contains the main keyword for my niche…
something like “Σοφιανός Ορθοπεδικά Είδη Αθήνα”February 15, 2020 at 4:45 am #1166040DavidStaffCustomer SupportI mean the HTML 🙂
So in the code you will see this:
<h1> <a href="%1$s" title="%2$s" rel="home"> <img %3$s /> </a> </h1>
You can edit the HTML to include any attributes you need eg.
<h1 title="my site title"> <a href="%1$s" title="%2$s" rel="home"> <img %3$s /> </a> </h1>
February 15, 2020 at 6:29 am #1166125johnapsso i can change the attribute title to title=“Σοφιανός Ορθοπεδικά Είδη Αθήνα”?
February 15, 2020 at 6:51 am #1166252DavidStaffCustomer SupportThats correct
July 18, 2021 at 2:04 pm #1860296CavalierPipThis solution breaks the REST API. I cannot search for plugins via the WP interface and some of the plugins (eg. Media Cleaner) throws an error after implementing this.
The minute I remove the solution, everything works. I have tried it multiple times to verify this.
July 19, 2021 at 1:48 am #1860667DavidStaffCustomer SupportHi there,
that snippet is specific to filter hooks in the GP Theme. The code only fires when that filter is reached in the GP template. It should not affect any other code especially on the backend.
Its more likely whatever the Media Cleaner plugin is doing to images that has caused the breakage.
So i had a search for that specific error and this was the top of the Google search results:
https://wordpress.org/support/topic/rest-api-is-disabled-or-broken-2/
I would ask the plugin author if he can take a look at the code as he may have some input on if the plugin would interfere with that.
July 19, 2021 at 2:57 am #1860735CavalierPipIt is not just that plugin. I disabled Media Cleaner (and other similar plugins I installed after implementing this solution). Now, as I said in the above post, I cannot search for plugins. It just keeps searching with no result. When I disable the solution, I get plugin search results immediately.
July 19, 2021 at 3:08 am #1860743DavidStaffCustomer SupportCan i suggest you raise a new topic – so we can help debug the issue with you. This will stop the OP from receiving unrequired notifications.
August 23, 2022 at 3:50 am #2321109TedGreetings,
I am trying to implement this snippet on my site. It’s not working because I don’t use a logo, just text as the logo. Could you suggest the code for this?Many thanks
August 23, 2022 at 5:41 am #2321196DavidStaffCustomer SupportHi there,
if you’re only displaying the Site Title and your home page is set to Display the Latest Posts then GP will automatically output the H1.
Are you using a static homepage ? Could i see the site ?
August 23, 2022 at 8:25 am #2321505Tedgreetings thanks for your reply,
yes it’s a static homepage. https://thegreatestsong.com. Not sure what to do.
-
AuthorPosts
- You must be logged in to reply to this topic.