Home > other >  display ads only when url number is met
display ads only when url number is met

Time:07-05

hello experts , i want to hide adsense ads on first page if post url domain.com/top-10-foods don't display if domain.com/top-10-foods/2 display if domain.com/top-10-foods/3 dispaly extra ....

i've tried this code did't work

<?php if(!is_post_url()); ?>
  <div id="myAd"></div>
<?php endif; ?>

i want to replace this code

<?php if(!is_post_url()); ?>

i'll be thankfull

CodePudding user response:

You are looking for the current page number in the context of pagination:

$pageNum = (get_query_var('paged')) ? get_query_var('paged') : 1;

if ($pageNum > 1) {
   // …
}

Please see WordPress Stack exchange for WordPress specific questions.

Also see the docs on pagination:

  • Related