0

I've had the same code on my wordpress site for more than a year, and it's stopped working. This is part of page.php:

<?php
if (is_page( 83571 )) { 
  include('adsense-schools.php');
} else { 
  include('adsense.php');
}
?>

Previously, this used to work, but today I noticed that it is not working correctly. adsense.php is included on all other pages, but adsense-schools.php does not show on page 83571. (And I have checked to make that sure that page id didn't change, the URL when editing that page ends in ...wp-admin/post.php?post=83571)

I also tried changing to page title instead of page id number, so

<?php
if (is_page( 'international-schools' )) { 
  include('adsense-schools.php');
} else { 
  include('adsense.php');
}
?>

But that didn't work either. Am I missing anything?

7
  • is_page() is for front-end use, not use in the admin panel. Might be easier to just check against $_GET['post'] – Howdy_McGee Apr 7 at 14:32
  • Sorry, I should have specified that this is in page.php – Lina Apr 7 at 16:08
  • And you're certain that 83571 is a post type = page and not a post or some other post type? – Howdy_McGee Apr 7 at 16:29
  • 1
    Yes. When I go to edit at the top it says "Edit Page" and not "Edit Post." – Lina Apr 7 at 23:15
  • have you checked that adsense-schools.php still exists and is unchanged? – Michael Apr 8 at 0:16
0

If nothing else works you can alternatively try the following:

global $post;

<?php if( $post->ID == 83571) { ?>

      include('adsense-schools.php');

<?php } ?>

New contributor
Ariel is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • Will this work if the page is a page and not a post? – Lina Apr 8 at 17:33
  • Yes it should. If you need to double check echo $post->ID. – Ariel 2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.