Add widget to header

Trying to follow Sarah Gooding's Post

https://premium.wpmudev.org/blog/how-to-widgetize-a-page-post-header-or-any-other-template-in-wordpress/

Declared new widget area in child theme's functions.php

Created header-home.php

where do I add my code to add the widget?

  • Paul Barthmaier
    • Code Wrangler

    Well, Pali Baacsi, haven't we told you already, you like to make things oh so difficult on yourself! Sure, you can do the things that you've outlined, but hey, don't come crying to us when they eff things up.

    Now with that disclaimer, I'm going to answer you, Pali, but only because I know you'll just keep asking, And even if you don't get an answer, you'll just go ahead an answer yourself! I'd suggest that there are medications available for this, but I ain't no doctor.

    Since you have added a header-home.php to your child theme, you might try adding your widget code into top-bar.php, then changing the reference to point to:

    /bp-social-child/lib/templates/wp-template/top-bar.php

    or something like that. But like I said, Pali, you really like to complicate things!

  • aecnu
    • WP Unicorn

    Greetings Pali Baacsi,

    You sir are absolutely hilarious :slight_smile: and it is a pleasure having you as a WPMU Dev Member!

    Part of the problem I suppose we are facing is that Sarah's post is well over two years old and WordPress has changed drastically since that time.

    You may find more satisfaction and accomplish this a bit easier with the Custom Widget Area plugin.

    Please let us know how it goes with my suggestion.

    Cheers, Joe

  • Paul Barthmaier
    • Code Wrangler

    Hey Joe,

    Thanks for your reply. I know there are plugins out there, but I figured I could waste more time trying to make it work. And I think have it figured out, as I mentioned above. The upside is I understand better now how the theme is put together and even a little more about PHP, so no real loss. Just trading time for knowledge, and how can that be bad, right?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.