为什么我在single.php中过滤每篇文章时都会得到它们的标题

为什么我在single.php中过滤每篇文章时都会得到它们的标题,php,wordpress,filtering,title,Php,Wordpress,Filtering,Title,我只是在页面和帖子中过滤标题,一切正常,但当我查看single.php时,它显示了实际的帖子,而我在functions.php插件内部处理的函数挂钩过滤器正在过滤我博客中每个帖子的标题,我希望只过滤当前帖子的标题: add_filter( 'the_title', 'ta_modified_post_title'); function ta_modified_post_title ($title) { if((in_the_loop())){ /**/ }

我只是在页面和帖子中过滤标题,一切正常,但当我查看single.php时,它显示了实际的帖子,而我在functions.php插件内部处理的函数挂钩过滤器正在过滤我博客中每个帖子的标题,我希望只过滤当前帖子的标题:

add_filter( 'the_title', 'ta_modified_post_title');
function ta_modified_post_title ($title) { 
    if((in_the_loop())){ 
      /**/
    }    
}
任何帮助都是感激的

谢谢,

add_filter( 'the_title', 'ta_modified_post_title');
function ta_modified_post_title ($title) { 
    if((some condition true)){ 
     $add_this = 'some string';
     $new_title = $title.' '.$add_this;
      return $new_title;
    }   

      return $title; 
}

当您查看任何帖子时,它都会通过single.php显示,因此当您查看它时,每个帖子都会成为当前帖子

我现在了解到,对于过滤器标题挂钩,从single.php查看单个帖子与查看整个博客是一样的。是否有一种过滤方法,条件是只检索single.php中当前帖子的标题?我确实尝试过像这样获取标题集ID,但显然我无法嵌套它

add_filter( 'the_title', 'ta_modified_post_title');
function ta_modified_post_title ($title) { 
    if((in_the_loop())){ 
      if(is_single()){
        $title=get_the_title(get_the_ID());
      }
    }    
}

我现在明白了,对于filter title hook,从single.php查看一篇文章与查看filter的整个博客是一样的。是否有一种过滤方法,条件是只检索single.php中当前帖子的标题?我确实尝试过类似的方法,但显然我无法嵌套它。