Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何仅在文章标题上应用wordpress筛选功能_Php_Wordpress - Fatal编程技术网

Php 如何仅在文章标题上应用wordpress筛选功能

Php 如何仅在文章标题上应用wordpress筛选功能,php,wordpress,Php,Wordpress,我是wordpress插件开发的新手。我想自定义wordpress帖子标题而不是页面标题。我写了这段代码 add_filter( 'the_title', 'change_title', 10, 1 ); function change_title( $title ) { $title = 'Posted: ' . $title; return $title; } 它会同时更改(页面和帖子)标题。如何仅对帖子标题应用此筛选器 add_filter('the

我是wordpress插件开发的新手。我想自定义wordpress帖子标题而不是页面标题。我写了这段代码

add_filter( 'the_title', 'change_title', 10, 1 );
function change_title( $title ) {
    $title = 'Posted: ' . $title;
    return $title;  
}
它会同时更改(页面和帖子)标题。如何仅对帖子标题应用此筛选器

add_filter('the_title', 'change_title', 10, 2);

function change_title($title, $id)
{
    if (get_post_type($id) == "post") $title = 'Posted: ' . $title;
    return $title;
}
享受

享受