Add Featured Widgets Inline Anywhere In Genesis

In this post, i’ll give you all the code you need to create widgets which display your content in-line.

There’s at least 2 ways to do this and i’ll provide the best 2 solutions for you to choose from.

Here’s an example of what can be done.

inline widgets

Update : You can now use CSS Grid to display any number and any type of widget inline. Here’s the CSS which assumes your PHP code which generates the widget includes the class, grid-container.

.grid-container .widget-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15ch, 1fr));
    grid-template-rows: auto;
    grid-gap: 1%;
    margin-top: 80px;
}

@media only screen and (max-width: 1023px) {

    .grid-container .widget-wrap {
        grid-template-columns: 1fr;
    }
    
}

And here’s both the PHP and CSS code which makes it all happen:

The conditional tag in the PHP code above displays the widgets before all posts assigned to the web design category only so you may need to change this statement to suit your own preferences.

The action hook in the code displays the widget before the content and sidebar which can also be changed easily.

Widget Settings

widget settings

You can use either the Genesis featured posts or pages widget. You could also use another type of widget like a text widget if you like.

four widgets

More Or Less Widgets

The code above generates 4 widgets in a row however you can easily change the value for the width in the CSS code for more or less.

This will enable you to display 2, 3, 5 or even 6 widgets inline as the code simply uses a percentage.

Here’s the CSS code you can change if you want more or less widgets:

.category-top .widget {
float: left;
padding: 0 2.8%;
width: 33.333333333333%;
}

This CSS code above can be used for 3 widgets.

This CSS code below can be used for 5 widgets:

.category-top .widget {
float: left;
padding: 0 2.8%;
width: 20%;
}

Customization Tips

1. If your post or page titles are too long, rather than select Show Post Title in the widget settings, you could un-check that box and add a custom title to the widget.

This way you can create smaller titles which are the same length which will look better.

2. Why not style each widget differently

3. The image size used in the PHP code is 100px width by 75px height. You can easily change that and regenerate thumbnails if needed. Don’t forget WordPress will generate an image that size for every image you upload.

Responsive Design

The easiest way to make sure these widgets don’t look messed up when viewed on small devices is simply to hide them by adding a couple of lines of CSS to your existing media queries located near the end of your child themes style.css file.

Here’s all the existing CSS code which includes the code to hide the widgets when re-sized on smaller screens:

@media only screen and (max-width: 1139px) {

	.site-inner,
	.wrap {
		max-width: 960px;
	}

	.content-sidebar-sidebar .content-sidebar-wrap,
	.sidebar-content-sidebar .content-sidebar-wrap,
	.sidebar-sidebar-content .content-sidebar-wrap {
		width: 740px;
	}

	.content,
	.site-header .widget-area {
		width: 620px;
	}
	
	.nav-widget { display: none; }

	.sidebar-content-sidebar .content,
	.sidebar-sidebar-content .content,
	.content-sidebar-sidebar .content {
		width: 400px;
	}

	.footer-widgets-1,
	.footer-widgets-2,
	.footer-widgets-3,
	.sidebar-primary,
	.title-area {
		width: 300px;
	}
	
		.category-top {
                 display: none;
}

}

Simply add this code to the max-width: 1139px section of your responsive CSS as you can see i’ve done in the code above:

.category-top {
display: none;
}

As soon as the screen reaches a certain width, the widgets will disappear.

Adding 4 Widgets Instead Of 1

4 widgets in a row

Here’s the 2nd solution which involves registering 4 widgets instead of one:

The same tips and responsive design apply to this method as the first.

More Ways To Display Content Inline


Comments

32 responses to “Add Featured Widgets Inline Anywhere In Genesis”

  1. You are the man. Thank you for the great resource.

  2. S it look slike you control how many simply by specifying the percentage size?

    So 1 widget would be 100 percent and two side by side would be 50%, right.

    How do you order these e.g. one widget area over a two widget area.

    Register one home-top and the second home-middle?

    1. Brad Dalton Avatar
      Brad Dalton

      Please clarify your question.

  3. I’m gonna try this on 1140 pro. Should I comment out the beginning of the default .css for the grid loop first?

    1. Brad Dalton Avatar
      Brad Dalton

      Bill

      The reason it didn’t work is because you didn’t read the post and follow the instructions.

      I tested the code and it works.

      Please try again.

  4. Tan Nguyen Avatar
    Tan Nguyen

    Hey I was able to make the widget visible but 4 of them not lining up like the screenshot above. Here’s what happening http://imageshack.com/a/img29/214/er2l.png

    1. Brad Dalton Avatar
      Brad Dalton

      Re-save your Permalinks and see if that fixes it.

      Otherwise you may need to reduce the width from 25% to 22 or 23%

      1. Tan Nguyen Avatar
        Tan Nguyen

        I did and still not working. Please help. I’m using the News Studiopress theme. Thanks

        1. Brad Dalton Avatar
          Brad Dalton

          It does work perfectly as i tested it.

          The screenshot proves that.

          You must have made a mistake somewhere.

          Please try again.

          1. Tan Nguyen Avatar
            Tan Nguyen

            Would you mind taking a picture of your screenshot on the News Studiopress theme?

          2. Brad Dalton Avatar
            Brad Dalton

            Why?

          3. Tan Nguyen Avatar
            Tan Nguyen

            To prove that I did something wrong.

          4. Brad Dalton Avatar
            Brad Dalton

            Tan

            You will need to tweak the code to work on different themes.

            You cannot expect to take code which works on one theme and expect it to work on every other theme.

            They are all coded slightly differently so you will need to work out what modifications need done on your theme.

  5. Bill Gram-Reefer Avatar
    Bill Gram-Reefer

    I am going to try this on eleven40 pro.

    Can a Home Bottom be created as well?

    TANGENT ALERT

    You know I was looking at this

    And thought that I can already do this in Genesis using widgets in content area and using categories within feature post. I don’t get the “issue” layer which I see as a child category of a broader term.

  6. Thanks a lot for quick reply.

    I am not a professional programmer, but I was having a close look at the codes of the first method and compared it with other posts which deals with arranging widgets “inline”. I was not able to find the command “inline” anywhere, so I thought probably that might be the reason.

    But as you said, the problem must be with the theme.

    Is there a tutorial somewhere as to how a non-technical person can convert the website from html to html5?

    Thanks a lot for the help. I will try the second method.

    Regards

    Raunek k

    1. Brad Dalton Avatar
      Brad Dalton

      There’s many resources available for converting Genesis child theme from XHTML to HTML 5.

      I also think this theme will be updated very soon so you may want to wait for the new version.

      I think the solution is very simple however i just need to find some time to dig in and trouble shoot the problem.

  7. Tried everything. Somehow the widgets doesn’t show in row.

    Should I try the second method of individual widgets?

    Thanks

    1. Brad Dalton Avatar
      Brad Dalton

      They did work for me when i tested the code on 2 different themes however not all code works in all themes so clearly you need to modify it slightly.

      Feel free to try the code which creates 4 widgets rather than one and see how you go however i think it will be the same result as the theme you are using is running the old XHTML markup and the 2 themes i tested the code on are running HTML 5.

      I will post an update with the solution for the older themes as soon as i have timer to troubleshoot however i do suggest you use a newer theme or at least convert your existing theme to HTML 5.

  8. Thanks a lot Brad.

    Trying to figure that out!!

    Thanks again!!

    Raunek k

  9. That’s great Brad, I think that was exactly the thing I was missing.

    However, there is now one another issue.

    The featured widgets displays posts one below the other, instead of in a row.

    I wish I could attach a screenshot, but I don’t see an option for that here.

    Thanks

    Raunek k

    1. Brad Dalton Avatar
      Brad Dalton

      Correct. You will need to modify the CSS to fix this.

      Every theme uses slightly different values for different properties.

  10. Thanks for the info Brad. That’s great news.

    BTW I love your website.

    It’s a great place for those who want to learn designing and customizing their own website.

    Thanks once again for all the information.

    Also, do you provide customization services? Is there an email address where I can send some more details?

    Thanks a lot

    Raunek k

    1. Brad Dalton Avatar
      Brad Dalton

      Please use the contact form on my site.

    2. Brad Dalton Avatar
      Brad Dalton

      I just tested the code on the News child theme and it works perfectly.

      You must have missed something.

      Don’t forget the original code included conditional tags so the widgets only display according to those conditions otherwise will not display. I believe this is what you are missing.

      You can remove the conditional tags which i have now done for you in the Gist above and the widgets will display site wide.

  11. I am using Studiopress News Theme.

    I have copied the exact code.

    I think probably it would not be working for the news theme.

    1. Brad Dalton Avatar
      Brad Dalton

      Thanks for that.

      Please give me some time and i will test it for you on the News theme.

      I think you’ll also find the news theme will be updated shortly as well.

  12. Hi Brad

    Thanks for the quick reply.

    I tried putting in all kinds of widgets and plugins. Even a simple text widget.

    But still nothing is visible.

    Raunek k

    1. Brad Dalton Avatar
      Brad Dalton

      You must have missed something because the screenshots prove the code works.

      And there’s 2 screenshots because i tested the code on 2 themes.

      There’s at least 2 ways to do this and its only a 2 minute copy and paste job.

      What theme are you using?

  13. Hi Brad

    I am using News theme by Studiopress (Genesis )

    I haven’t modified the code. I added the codes in function.php and style.css

    I am able to see the additional widget “category-top” in the widget area. But when I add featured amplified widget, it doesn’t display anything.

    I am trying to figure the problem, but doesn’t seem to get to a solution.

    Raunek k

    1. Brad Dalton Avatar
      Brad Dalton

      Understand and would love to help but i have no control over that plugin.

      If its not working for you, you can ask the plugin author what the problem is or use another plugin.

      No need to worry because there’s 30000 to choose from.

      Please find another.

      The widgets i used where the Genesis Featured Post widgets not the amplified version.

  14. Hi Brad

    thanks for the tutorial.

    I am following all the steps mentioned in the first method, but still not able to display the widget.

    Is there something to do with the hooks or function.php file?

    Thanks in advance.

    Raunek k

    1. Brad Dalton Avatar
      Brad Dalton

      Hi Raunek

      Where are you adding them?

      Have you modified the code in any way?

      What theme are you using?

Leave a Reply

Join 5000+ Followers

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