- This topic has 7 replies, 3 voices, and was last updated 5 years, 11 months ago by Tom.
-
AuthorPosts
-
April 27, 2018 at 2:21 am #561633Antar
Hello, All –
I want to show a small logo graphic with the site title (text) displayed to the right of it. Unfortunately, the normal order of the elements in the header is to show the site title text and then the logo graphic. There is no way in the customizer to swap the elements around so I’m delving into the templates to do it manually.
I’ve opened up the inc/structure/header.php file and can see the code for constructing the elements.
The Site Title and Tagline are contained within the a div with the class “site-branding”.
The logo graphic is contained within “site-logo”.What I find confusing in the template code is that the site-logo element is created before site-branding – and yet on the actual page they are rendered in completely the opposite order! Clearly I do not understand how this is supposed to work.
Can someone please help put me right?!
:0)
Antar
April 27, 2018 at 2:46 am #561663JamalHi
Have a look at how you can achieve what you want with css
https://docs.generatepress.com/article/putting-site-title-next-logo/
Hope that was useful
April 27, 2018 at 3:03 am #561675AntarHi, Jamal –
Thanks for this. It does work – however, I still want to learn about the template structure. I don’t get how the code for the logo appears before the code for the branding in the template – but on the page the text appears before the graphic!
On line 69 of the header.php template is:
function generate_construct_logo()
Followed on line 143 by:
function generate_construct_site_title()
The logo is generated before the branding. So, which part of the code dictates the order of these elements when rendered on the page?
Thanks,
Antar
April 27, 2018 at 10:45 am #562015TomLead DeveloperLead DeveloperThe order of the functions doesn’t have any say on how they’re displayed when rendering your actual site.
This function controls the order: https://github.com/tomusborne/generatepress/blob/2.0.2/inc/structure/header.php#L56
Let me know if you need more info π
April 27, 2018 at 11:00 am #562019AntarHi, Tom –
Thanks for your support. I half guessed this would be the answer. The only problem is that it doesn’t work if you copy the file and add it to your child theme structure. It only works if you edit the header.php in the generatepress theme folder.
Does this mean there are some template files that you can’t duplicate/overwrite with a child theme?
Note: I’m only asking because I want to learn something!
:0)
Antar
April 27, 2018 at 11:09 am #562020TomLead DeveloperLead DeveloperCorrect – only root level template files can be overwritten.
However, this function is pluggable, so you can add it to your child theme and change it:
if ( ! function_exists( 'generate_header_items' ) ) { function generate_header_items() { generate_construct_header_widget(); generate_construct_site_title(); generate_construct_logo(); } }
April 27, 2018 at 11:39 am #562045AntarOK. I understand. I hadn’t realised about the root templates. No wonder some of my edits don’t work!
Thanks for your help.
π
April 27, 2018 at 4:16 pm #562169TomLead DeveloperLead DeveloperYou’re welcome π
-
AuthorPosts
- You must be logged in to reply to this topic.