Community Forums › Forums › Archived Forums › Design Tips and Tricks › Ads in grid style
- This topic has 11 replies, 2 voices, and was last updated 11 years ago by
viorelepuran.
-
AuthorPosts
-
March 3, 2014 at 2:36 am #93152
viorelepuran
MemberHello guys,
I am using a child theme with genesis, and i created a category.php to display post in grid layout.
So now, my post are beeing displayed on 2 columns.
Now i want to add a adsense ad after the first 6 posts.
So it needs to be 6 posts, and after those 6 posts, a area as width as the 2 column post, containing the AD.
Here is the file for category, in pastebin
http://pastebin.com/wxzBMUpt
I think it needs some tweeks on line 13 , but i do not know how to do it.
Can someone help me with it?
I saw a example from someone, but i think it is not for grid style.Here it is:Ah! Now I understand. Try replacing:
<?php
if (have_posts()) : while (have_posts()) : the_post();
get_template_part('post', 'homepage');
endwhile;
with:<?php
if (have_posts()) : $c = 0; while (have_posts()) : the_post();
$c ++;
get_template_part('post', 'homepage');
if ($c > 2 ) {
$c = 0;?>
[ insert ad code here ]
<?php
}
endwhile;Here you can see how the end result should look like.
http://postimg.org/image/qlawdlyc7/
Thank you !
http://test.sneakerbardetroit.com/March 3, 2014 at 2:47 am #93153Brad Dalton
ParticipantPlease paste all the code in a Github Gist and embed the Gist here. Thanks
March 3, 2014 at 2:50 am #93154viorelepuran
MemberHy brad, thank you for your reply.
I did as you told me to do.Please tell me if the code from category.php is enough, or if you need something else.
<script src="https://gist.github.com/anonymous/9320928.js"></script>March 3, 2014 at 3:01 am #93158viorelepuran
MemberWhy can i not embed the Gist here?
Can you see the code?March 3, 2014 at 3:11 am #93161viorelepuran
MemberMarch 3, 2014 at 5:25 am #93170Brad Dalton
ParticipantMarch 3, 2014 at 5:26 am #93171viorelepuran
Memberis this ok?
March 3, 2014 at 5:45 am #93173viorelepuran
MemberYes, it is ok now.
Do you have any ideea of how to place a ad after the 6th post, like shown in the bellow image?
http://postimg.org/image/qlawdlyc7/March 3, 2014 at 6:41 am #93175Brad Dalton
ParticipantChange the 1 in the code to a 6 http://wpsites.net/web-design/add-content-after-any-number-of-post-excerpts-in-any-type-of-archive/
March 3, 2014 at 7:35 am #93190viorelepuran
MemberThank you for your effort. I tried all 4 codes on the link you gaved me, but only the las one seems to work for me.
The thing is that it replaces the 6th post excerpt withe the add.I need it to place the ad bellow excerpt, and to be as whidth as the 2 columns. I think the first code, with black background would work, but maybe i am doing something wrong...
Can you please look again at that code?
Here is the link with the working last code
http://test.sneakerbardetroit.com/March 3, 2014 at 8:23 am #93195Brad Dalton
ParticipantI tested all of them and they all work perfectly.
I also tested this solution on a HTML 5 theme using the grid loop on the home page with this code and i know for a fact it works.
https://gist.github.com/braddalton/617807f3310b87ded754
March 3, 2014 at 8:26 am #93197viorelepuran
MemberIt does not works...would it help you if i gave you access to ftp and wp-admin?
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.