【发布时间】:2022-07-15 04:40:40
【问题描述】:
我在functions.php 中放置了以下最小的 PHP 代码,它可以工作。
add_action( 'init', 'test' );
function test() {
echo 'Testing...123';
}
但是如果我用is_front_page()指定只在首页应用这个(front-page.php),那就不行了,为什么会这样呢?
if ( is_front_page() ) {
add_action( 'init', 'test' );
function test() {
echo 'Testing...123';
}
}
【问题讨论】:
-
在您的 WP 设置中,您是否将特定页面设置为静态首页?如果没有,
front-page.php永远不会被引用。
标签: wordpress