Skip Navigation

[Resolved] Placing Google Ad in post view

This thread is resolved. Here is a description of the problem and solution.

Problem:

I tried using the following code to show Google Ad in the middle of the view, I set the view to output 11 posts in a page, but this instead resulting post #5 to be replaced with the ad instead (thus the post was not shown). Is this an expected behavior?

Solution:

This is expected result, in the item #5, you will need to display the content template shortcode too, otherwise it won't display #5 item, for example:

https://toolset.com/forums/topic/placing-google-ad-in-post-view/#post-1260743

Relevant Documentation:

This support ticket is created 3 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by deanL 3 years, 5 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#1260637

I tried using the following code to show Google Ad in the middle of the view:

<wpv-loop>
[wpv-item index=split2]
<div class="row">
{Google Adsense code}
</div>
[wpv-item index=other]
[wpv-post-body view_template="loop-item-in-top-stories-of-the-region"]
</wpv-loop>

I set the view to output 11 posts in a page, but this instead resulting post #5 to be replaced with the ad instead (thus the post was not shown). Is this an expected behavior?

Also, this may be beyond your support scope, but in your knowledge, have you come across the issue of Responsive Google Ad breaking the bootstrap grid (see this screen recording: hidden link)? What happens was, on initial page load, the columns would go haywire (where the ad was inserted within), but if I resized the browser or simply activated code inspector, the layout restored itself. Meanwhile I have removed the code so you won't be able to see the problem in production site.

#1260743

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hello,

This is expected result, in the item #5, you will need to display the content template shortcode too, otherwise it won't display #5 item, for example:

<wpv-loop>
[wpv-item index=split2]
[wpv-post-body view_template="loop-item-in-top-stories-of-the-region"]
<div class="row">
{Google Adsense code}
</div>
[wpv-item index=other]
[wpv-post-body view_template="loop-item-in-top-stories-of-the-region"]
</wpv-loop>
#1261175

Ah I see what you mean now! Silly me didn't think of that! Thanks very much as always!