I am using 3 columns grid in woocommerce shop
[] [] []
[] [] []
[] [] []
How can I insert a div after the 3rd grid
Something like this
[][][inserted div]
[][][]
[][][]
So I can put anything in there, thanks.
I am using 3 columns grid in woocommerce shop
[] [] []
[] [] []
[] [] []
How can I insert a div after the 3rd grid
Something like this
[][][inserted div]
[][][]
[][][]
So I can put anything in there, thanks.
you can achieve this by using jQuery also,
Try the CSS selector :nth-child():
All the product loaded from a loop script just initiate any
$variable= 0
and after every product loaded$variable incremented by 1
and check$variable %3 == 0
if success add the divYou can place this inside your post loop just before the loop ends. It will output your desired div (ad) after the 2nd post. Just make sure you add in any necessary CSS classes to the div, and of course your ad code or image.
So it should look something like this within your post loop:
This works by using the
$current_post
property of the WP_Query class. It retrieves the index of your current post in the loop.Hope this helps!