下面的函数将所有页面的所有标题包装为*符号。我想更改该函数,使其仅对单个帖子的标题应用过滤器。我如何才能做到这一点?
function apply_titles($title, $id) {
return "* ".$title." *";
return $title;
}
add_filter(\'the_title\', \'apply_titles\', 10, 2);
下面的函数将所有页面的所有标题包装为*符号。我想更改该函数,使其仅对单个帖子的标题应用过滤器。我如何才能做到这一点?
function apply_titles($title, $id) {
return "* ".$title." *";
return $title;
}
add_filter(\'the_title\', \'apply_titles\', 10, 2);
如果只想换行文章标题,那么应该使用get_post_type()
检查立柱类型。您可以参考以下代码,它将仅应用于“post”post类型。如果你想在一个页面上申请,那么你必须添加is_single()
具有get_post_type()
条件
function apply_titles($title, $id) {
if(\'post\' == get_post_type($id) && is_single())
{
return "* ".$title." *";
}
return $title;
}
add_filter(\'the_title\', \'apply_titles\', 10, 2);
我想输出所有apply\\u过滤器和do\\u操作,以向用户提供它们的概述。如果我使用代码add_filter( \'wpErpOs_testFilter\', \'wpErpOs_testFilter_callback\', 10, 1 ); function wpErpOs_testFilter_callback( $testVar ) { $testVar[] = \"GM\"; return $testVar; } $testVar = array(\"V