何时是函数中的代码。是否执行php?是在循环中吗?当置于函数中时,以下各项不起作用。php(不在函数内):
if (is_page( 27 )) {
echo \'this is the apply page\';
}
法典规定is_page() 无法在循环内运行。何时是函数中的代码。是否执行php?是在循环中吗?当置于函数中时,以下各项不起作用。php(不在函数内):
if (is_page( 27 )) {
echo \'this is the apply page\';
}
法典规定is_page() 无法在循环内运行。is_page()
依靠一个完整的全球$wp_query
对象如果你在行动前打电话template_redirect
可能无法获取该数据。
等待适当的操作。
示例:
add_filter( \'template_include\', function( $template ) {
if ( is_page( 27 ) )
echo \'this is the apply page\';
return $template;
});
你可以打电话is_page()
也在循环中。首先,您需要通过调用页面IDget_the_ID(); 函数,则可以使用如下is\\U页函数:
$id = get_the_ID();
if ( is_page( $id == 2591 ) )
{
return __( \'Add to cart\', \'woocommerce\' );
}
else
{
return __( \'BUY NOW\', \'woocommerce\' );
}
我正在尝试将循环拆分为4列。我的逻辑有很大的缺陷,我的布局也有问题。这么简单的问题,但我正在努力解决。我基本上需要将每组四根柱子包装在一个容器“行”分区中。当然,剩下的任何柱子,即使少于四根,也要进行包装。<div class=\"twelve columns\"> <?php $i = 0; if (have_posts() ) : while ( have_posts() ) : the_post();