A couple of plugins and themes support infinite scroll so that your visitors can read more articles on the same page just by scrolling down.
You can tell Advanced Ads to inject ads into this infinite scroll content by default.
Since there is no technical standard, the solution to show ads can vary. This page covers our current knowledge to show ads in AJAX-loaded content.
Table of Contents
How to enable AJAX-loaded ads?
These are a few solutions to show ads in AJAX-loaded infinite scroll content.
Disable ads on secondary queries
Disable the Disable ads on secondary queries option in Advanced Ads > Settings > General > Disable Ads. If enabled, it prevents ads in content loaded using AJAX
Enable Secondary Queries
In case you are using the General Conditions in the Display Conditions on the ad edit screen, then make sure to enable Secondary Queries.
Set Unlimited ad injection
The Unlimited ad injection setting in Advanced Ads > Settings > General > Content injection allows you to enable ads on archive pages and outside of “single pages”. Set this option to -1 or anything above 0 to enable ads in AJAX-loaded content and infinite scroll.
Developers, set is_singular() and in_the_loop()
Developers of AJAX-loading plugins or themes should make sure that is_singular() and in_the_loop() return true in their content. You could add something like this to your loop:
global $wp_query; $wp_query->is_single = true; $wp_query->is_singular = true; $wp_query->in_the_loop = true;
Privacy: TCF 2.0 integration
When our TCF 2.0 integration is used, ads loaded using AJAX are disabled until consent is given. Due to the technical nature of infinite scroll, the ads loaded via infinite scroll will only show when Advanced Ads Pro is enabled.
Advanced Ads automatically disables the cache-busting feature for ads loaded using AJAX since AJAX-loaded content is practically like cache-busting.
Due to the removed Cache busting script from AJAX calls, the following features are not explicitly working for ads placed within AJAX-loaded content.
- Ad groups that rotate every x seconds
- Lazy loading is disabled but works because the AJAX-loaded content is practically lazy-loaded
There is still a chance that your ads are not injected into AJAX-loaded content due to an issue that could also happen to normal content. Please check this general list.
It is possible that Display and Visitor Conditions are not working for ads in AJAX-loaded content. We would like to check individual solutions. Please contact us.
Tested plugins and themes
These are plugins and themes we tested the above solutions on.
AJAX Load More
- set Unlimited ad injection and allow ads in Secondary Queries to show ads
- their premium version does have its own caching, which does not work in combination with Advanced Ads Pro cache-busting. You either have to disable their caching or Cache busting for the placements in the content