Adding PHP code to the headerViewing 12 posts - 1 through 12 (of 12 total)
July 11, 2016 at 8:18 pm #9274
This is a continuation of this thread: http://support.creiden.com/forums/topic/is-it-possible-to-add-a-widget-to-a-header/#post-9133
I’m unsure why the thread was closed. I don’t believe I closed it and I still have questions.
I decided to add php code to header-text-block.php instead of adding the shortcode functionality, however when I add the file to my child theme, it isn’t being recognized. Can you tell me if I need to add something to my functions.php to get it working?
Thanks in advanceJuly 17, 2016 at 8:01 pm #9344
The thread is closed because as i told you there is no possible way to add widgets to the header.
Unfortunately i can’t help you with a code that i can’t see, and specifically with a code that we didn’t write.
There is nothing special with the child themes, just duplicate the file with the same path and you should get it working, no need to require the file again, Just make sure from the file path as i noticed that you are adding the file in the theme folder directly from what you wrote here ” get_stylesheet_directory() . ‘/header-text-block.php’ ); ”
I hope that this helps
Best RegardsJuly 18, 2016 at 7:32 pm #9350
I can appreciate that you can’t help with code that you didn’t write, however, I was under the impression that this theme is child theme friendly. So perhaps you can help me with that.
I had tried both duplicating the file path and then adding the file with ‘require once’ in functions and I haven’t had any luck.
Nevermind the code for now, I’m just trying to get the file working in my child theme in the most basic way possible, so I’ve tweaked line 68 to test to see if my file in my child theme is showing up.
<p>test <?php echo htmlspecialchars_decode($text); ?></p>Just in case I’ve missed something, here’s the path that I’ve replicated creiden-framework > header-builder > blocks. I would think that my word ‘test’ should show up, but it isn’t.
Let me know if you need any more info, and thanks in advance.July 21, 2016 at 5:43 pm #9413
Unfortunately child themes work only on replacing either the style.css or template files that is called via get template so there is no way to replace this file as it is required with require_once and it is not handled as a template.
So the only way to solve your problem is to change the code directly and before updating the theme take a backup from the file and update the theme and replace the file again to maintain what you have done
I hope that this helps
Best RegardsJuly 25, 2016 at 6:23 pm #9455
This isn’t a good solution for me as I’m doing this set-up work for a client and when the work is done, I’ll be handing it over for the client to maintain. They don’t wish to pay me to make these kinds of changes every time the theme is updated.
I’m wondering if any of these discussions/pages could help us:
ThanksJuly 26, 2016 at 11:26 am #9463
Any solution requires modification to the core theme to transfer all the rendering of the header builder blocks to be templates so that they can be overridden normally, any other solution will not follow the scope of the wordpress.
I will be working on it for version 2.8 and hopefully we will find a proper solution
Best RegardsJuly 26, 2016 at 7:04 pm #9489
Thanks for letting me know. It would be great if you could keep me posted on this one. Thanks
Bishoy MelekModeratorAugust 22, 2016 at 10:23 pm #9788
You can now override any block in the header builder and add the code that you want in your child theme, with the latest version 3.1 this feature should work properly
Please let us know if it is solved or there is still any problem with it
Waiting for your feedback
The topic ‘Adding PHP code to the header’ is closed to new replies.