Add Multiple Widgets Using The Same Hook Position

For some reason, you may want to add more than one custom widget area in the same genesis_hook position. To do this you can use the same div class in the function so the styling is exactly the same for each or you can use a unique class for each.

In this code, you’ll see 2 different classes meaning you can style each widget differently.

Copy this code from the view raw link and paste it at the end of your child themes functions.php file using your favorite code editor like Notepad++.

The reason this code works and outputs the content for each widget one after the other is because of the 3rd parameter which has been added to the code.

The 1st widget uses a priority of 5 and the 2nd uses a priority of 6.

This results in the first widget displaying first in the hook position you include in the code (genesis_after_post).

The second widget displays below the first because it has a priority of 6 giving the first widget priority positioning when using the same hook.

You could add more widgets to the same hook as long as you add a priority to each action which is below 10. If you used a priority above 10, your widget would display below the comments form.

A Better Way To Create Multiple Widgets?

Know of a more efficient way to add multiple widgets to the same hook location in Genesis?


Comments

3 responses to “Add Multiple Widgets Using The Same Hook Position”

  1. John Schuster Avatar
    John Schuster

    I think it worked out, I had to add another closing div tag.

    Thank you,

    Brad you have so much great wordpress php content I started appending your name onto my Google searches.

    😉

    1. Brad Dalton Avatar
      Brad Dalton

      No worries John.

  2. John Schuster Avatar
    John Schuster

    Another helpful article thank you Brad!

    I am trying to give a separate background to the second div. The second widgets div is starting at the hook above the first widget.

    How do I tell the second widget div to start at the bottom of the first widget div and not at the top of the hook?

    For now I am using a z index and relative positioning to move it.

    Thanks.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.