我正在尝试在运行正确的$ description时触发函数(a)和(b),但到目前为止我还没弄清楚。它可能非常简单。
服务器被锁定到php 5.2
add_filter( 'category_description', 'so_31889614_category_description', 10, 2 );
function so_31889614_category_description ( $description, $category )
{
//testing with var_dump shows [int(7)] [int(2)] and [int(3)] in the proper places on the pages
var_dump( $category );
if ( $category->term_id == 2 || $category->term_id == 3 ) {
$description = a();
} elseif ( $category->term_id == 7 ) {
$description = b();
} else {
$description;
}
return $description;
}
function a($content) {
//stuff
return $content;
}
function b($content) {
//stuff
return $content;
}
感谢您的帮助。
答案 0 :(得分:1)
您似乎有两个返回数据的函数,但您没有在描述中告诉函数期望。
$description = a('Put description a here');
$description = b('Put description b here');
答案 1 :(得分:0)
原来这是一个if is_category
声明问题。
能够通过以下
解决我自己的问题add_filter( 'category_description', 'so_31889614_category_description', 10, 2 );
function so_31889614_category_description ( $description, $category )
{
if( is_category( array(2,3) ) ) {
$description = a($content . $output);
} elseif ( is_category( array(7) ) ) {
$description = b($output2);
} else {
$description = a($content . $output);
}
return $description;
}