Add new widget for ads after 2 or 3 posts in Genesis Theme
Updated On May 23, 2015 March 12, 2014 -Written ByDo you want to add new widget area after 2, 3 or 4 posts on homepage of your Genesis Theme? New widget area can be used for almost anything: be it Adsense Ad code, newsletter sign up box, social media button, any random text or image.
Add new widget area between posts in Genesis
1. Paste the following code in the end of functions.php file. Remember to backup your functions.php file before making changes.
https://gist.github.com/9510445
2. Then go to Appearance > Widgets area, you should see new “Between Posts Area” section. Drag and drop any widget into this section to display it after 3 posts on homepage.
3. You can customize this widget area by adding specific (.between-posts-area ) class to your style.css file. Add following code to style.css (this is a sample code and can be modified to your specific requirements).
[cc]
.between-posts-area .wrap{
background:#ddd;
color:#444;
margin-bottom:20px;
padding:20px;
text-align:center;
clear:both;
}
[/cc]
4. You can also customize “after number of posts” this new widget box should appear, just change “3” number in the code. You can also change loop counter value (currently 0 in the code). For example: If you want to display this new widget after 3 post only once. Considering that you have 10 posts showing on homepage, then set loop counter value to 10.
That was awesome and it just what I was looking for. But what if I just want to show a widget after 3 posts and no-repetitions i.e, the widget should not appear again in the loop.
Check out step #4.
You can also customize “after number of posts” this new widget box should appear, just change “3” number in the code. You can also change loop counter value (currently 0 in the code).
For example: If you want to display this new widget after 3 post only once. Considering that you have 10 posts showing on homepage, then set loop counter value to 10.
Thanks a lot for the tutorial, exactly what I was looking for. :)
I just now found this tutorial, and I thank you for posting. Works like a charm and its hard to find good tutorials for genesis that are reliable.
Is there anyway to add multiple widgets between posts?
Hi Davinder, this was just great and exactly what I needed. However, I’m facing some problems with CSS. The new area wraps the first three articles and all styles I add affect them too, see image > http://puu.sh/pVYlS/269da7afc9.jpg
Any idea about what I need to change or add to separate the posts from the new widget section?
Thanks!
Hi,
This is awesome, and works like a charm! I am a complete noob wrt coding and all, so my question might sound really stupid, but here goes: I have blog content showing on the front page / homepage. And obviously there is a separate page where all the blog posts are. I don’t want the front page to show this Between Posts Widget Area. How can I tweak the code such that it shows only the Blog Page, but not on the front page?
thank you this was awesome and do what i need