Я пытаюсь запустить функции (а) и (б), когда запускается правильное описание $, но до сих пор я не мог понять это. Вероятно, это что-то действительно простое.
Сервер заблокирован в 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;
}
Спасибо за любую помощь.
if is_category
проблема с 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;
}
Кажется, у вас есть 2 функции, которые возвращают данные, но вы не вводите описание, которое вы рассказываете о ожидаемых функциях.
$description = a('Put description a here');
$description = b('Put description b here');