Wordpress-发布前过滤帖子内容
我正在使用电子邮件发布到Wordpress博客,我想在[title shortcode]之前过滤所有内容。我一直在尝试一些事情,但没有成功。这就是我所拥有的:Wordpress-发布前过滤帖子内容,wordpress,Wordpress,我正在使用电子邮件发布到Wordpress博客,我想在[title shortcode]之前过滤所有内容。我一直在尝试一些事情,但没有成功。这就是我所拥有的: <?php function filter_handler( $data , $postarr ) { // do something with the post data $post_content = $postarr['post_content']; strstr($post_content, '[title'); }
<?php
function filter_handler( $data , $postarr ) {
// do something with the post data
$post_content = $postarr['post_content'];
strstr($post_content, '[title');
}
add_filter( 'wp_insert_post_data', 'filter_handler', '99', 2 );
找到了答案
function changePost($data, $postarr) {
$data['post_content'] = strstr( $postarr['post_content'], '[title' );
return $data;
}
add_filter('wp_insert_post_data','changePost','99',2);