admin管理员组文章数量:1295875
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?
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?
Share Improve this question edited Apr 7, 2021 at 16:09 Lina asked Apr 7, 2021 at 13:46 LinaLina 112 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 0If nothing else works you can alternatively try the following:
global $post;
<?php if( $post->ID == 83571) { ?>
include('adsense-schools.php');
<?php } ?>
本文标签: phpIf ispage includeelse not working all of a sudden
版权声明:本文标题:php - If is_page includeelse not working all of a sudden 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741628198a2389202.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
is_page()
is for front-end use, not use in the admin panel. Might be easier to just check against$_GET['post']
– Howdy_McGee ♦ Commented Apr 7, 2021 at 14:3283571
is a post type = page and not a post or some other post type? – Howdy_McGee ♦ Commented Apr 7, 2021 at 16:29