只有在添加新帖子时,我才想在第一次保存到数据库之前编辑内容,所以我会检查路径是否位于新帖子。php我想应用过滤器,但它不起作用。有人知道怎么解决这个问题吗?
$pagePath = parse_url( $_SERVER[\'REQUEST_URI\'] );
$pagePath = $pagePath[\'path\'];
$pagePath = substr($pagePath, 1);
if($pagePath === \'wp-admin/post-new.php\'){
function my_filter_function_name( $content ) {
return $content . \'text before save to db\';
}
add_filter( \'content_save_pre\', \'my_filter_function_name\', 10, 1 );
}