在我使用的插件中
add_filter(\'wp_insert_post_data\',\'filter_blog_post_data\');
用于在博客数据保存到数据库之前对其进行过滤。
但是这个钩子post-new.php
加载最新帖子的数据,如permalink、slug、author。
Note:
我正在使用Wordpress 4.4.13
.在我使用的插件中
add_filter(\'wp_insert_post_data\',\'filter_blog_post_data\');
用于在博客数据保存到数据库之前对其进行过滤。
但是这个钩子post-new.php
加载最新帖子的数据,如permalink、slug、author。
Note:
我正在使用Wordpress 4.4.13
.不确定这一定是什么原因造成的。尝试使用以下格式的函数复制整个筛选器挂钩:
function filter_handler( $data ) {
// do something with the post data
return $data;
}
add_filter( \'wp_insert_post_data\', \'filter_handler\', \'10\', 1);
如果发生什么事,请告诉我。关键是里面有什么filter_blog_post_data
. 此筛选器返回的数组也将应用于您的新的尚未保存的帖子。
function wpse_288685_filter_data( $data, $postarray ){
$data[\'post_name\'] = \'foo-bar\';
return $data;
}
add_filter(\'wp_insert_post_data\', \'wpse_288685_filter_data\', 10, 2);
此函数将post slug设置为foo-bar
即使您的post-new.php
页只剩下“阅读更多”问题。<?php while(have_posts()): the_post(); echo \'<h2>\'.get_the_title().\'</h2>\'; echo get_the_post_thumbnail(get_the_ID(),\'medium\'); the_excerpt(); echo \"&