Adding PHP code to the header

  • Adding PHP code to the header
    Viewing 12 posts - 1 through 12 (of 12 total)

  • heather
    Participant
    #9274

    Hi,

    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 advance


    heather
    Participant
    #9334
    This reply has been marked as private.

    Bassam Tarek
    Keymaster
    #9344

    Hi Heather,

    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 Regards


    heather
    Participant
    #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.


    Bassam Tarek
    Keymaster
    #9413

    Hi Heather,

    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 Regards


    heather
    Participant
    #9455

    Hi,

    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:
    https://developer.wordpress.org/themes/advanced-topics/child-themes/
    http://wordpress.stackexchange.com/questions/26822/how-to-override-javascript-files-in-child-theme/26824#26824
    https://wordpress.org/support/topic/overriding-parent-theme-sub-files-with-a-child-theme-how

    Thanks


    Bassam Tarek
    Keymaster
    #9463

    Hi Heather,

    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 Regards


    heather
    Participant
    #9489

    Thanks for letting me know. It would be great if you could keep me posted on this one. Thanks


    Bishoy Melek
    Moderator
    #9493

    sure @heather, We will let you know the updates.

    My Regards,


    Bassam Tarek
    Keymaster
    #9751

    Hi @heather,

    The feature of overriding the header builder blocks through child theme is done and working properly, We will release it in the next version most probably at the beginning of the next week

    Best Regards


    heather
    Participant
    #9770

    Amazing! Thank you!


    Bassam Tarek
    Keymaster
    #9788

    Hi heather,

    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
    Thanks

Viewing 12 posts - 1 through 12 (of 12 total)

The topic ‘Adding PHP code to the header’ is closed to new replies.