I am trying to: insert google adsense code block in to the my wpv-loop on homepage.
I created new post type for show only on my homepage. I have 12 posts But on my homepage show only 10 posts. I think when i add my adsense code used [wpv-item index=5] and [wpv-item index=10] they not show my 2 posts (change them in ordering) on front-end hidden link 🙁 but show advertisement.
In my view:
Content Selection: Post types
Ordering: Menu order
Limit and Offset: no limits
My code
<div class="masonry-grid">
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-item index=other]
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 grid-item">
[wpv-post-body view_template="WordPress Archive 4 - loop item"]
</div>
[wpv-item index=5]
<div class="adsense">
<div style="min-width:250px;min-height:90px;">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- art-right -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1600766785861567"
data-ad-slot="6629282616"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
[wpv-item index=10]
<div class="adsense">
<div style="min-width:250px;min-height:90px;">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- art-right -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1600766785861567"
data-ad-slot="6629282616"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
</wpv-loop>
<!-- wpv-loop-end -->
</div>
Thank you for help
Dear Rostislav,
You are right, you will need to display the content template "WordPress Archive 4 - loop item" in both the 5th and 10th items, for example:
...
[wpv-item index=5]
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 grid-item">
[wpv-post-body view_template="WordPress Archive 4 - loop item"]
</div>
...
[wpv-item index=10]
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 grid-item">
[wpv-post-body view_template="WordPress Archive 4 - loop item"]
</div>
...
And how i can insert my adsense code block to 5,10 place?
I need show all my post in my loop. And insert code between my row.
you can try this:
find the code:
and
and add the content template codes and adsense codes just below them:
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 grid-item">
[wpv-post-body view_template="WordPress Archive 4 - loop item"]
</div>
I'll add my code which you advised but it break my loop! see screenshot.
I repeat my question;
I have 12 post i need show all posts and beetween them my adsense code. I try make as in your docementation https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-item (i recently asked https://toolset.com/forums/topic/how-to-insert-adsense-code-in-mansory-grid/) And in fact i get 10 posts and 2 adsense block. (see another screenshot)
How resolved my problem?
Since it is a custom codes problem, please provide a test site with same problem, and fill below private detail box with login details, also point out the problem page URL and view URL, I need a live website to test and debug. thanks
I have modified the codes as below:
[wpv-layout-start]
[wpv-items-found]
<div class="masonry-grid">
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-item index=other]
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 grid-item">
[wpv-post-body view_template="WordPress Archive 4 - loop item"]
</div>
[wpv-item index=4]
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 grid-item">
[wpv-post-body view_template="WordPress Archive 4 - loop item"]
</div>
<div class="adsense">
<div style="min-width:250px;min-height:90px;">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- art-right -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1600766785861567"
data-ad-slot="6629282616"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
[wpv-item index=8]
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 grid-item">
[wpv-post-body view_template="WordPress Archive 4 - loop item"]
</div>
<div class="adsense">
<div style="min-width:250px;min-height:90px;">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- art-right -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1600766785861567"
data-ad-slot="6629282616"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</div>
</wpv-loop>
<!-- wpv-loop-end -->
</div>
[/wpv-items-found]
[wpv-layout-end]
<ul class="pagination-container">
[wpv-pagination]
[wpv-pager-archive-prev-page][wpml-string context="wpv-views"]Попередня сторінка[/wpml-string][/wpv-pager-archive-prev-page]
[wpv-pager-archive-nav-links]
[wpv-pager-archive-next-page][wpml-string context="wpv-views"]Наступна сторінка[/wpml-string][/wpv-pager-archive-next-page]
[/wpv-pagination]
</ul>
[wpv-no-items-found]
<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]
Please test again, check if it is fixed or not
Thank you. it's look as i need. I see you change only number of post in - [wpv-item index=4] and add adsense code below them? or i'm wrong?
Yes, you are right, that is what I did