Please, backup your database before running this.
代码非常简单,并在本地WordPress中进行了测试<这个建议只是为了预防,因为我想你正在处理一个实时站点。
将代码复制到PHP文件中,将其上载到plugins文件夹并激活。
激活时,它将遍历所有posts
发布类型并检查是否有摘录如果没有,请检查是否有多功能一体式描述如果有,请在摘录中填写此信息
<?php
/*
Plugin Name: AIOSEOP to Excerpt
Plugin URI: http://wordpress.stackexchange.com/q/70990/12615
*/
register_activation_hook( __FILE__, \'wpse_70990_activation_run\' );
function wpse_70990_activation_run()
{
$args = array(
\'post_type\' => \'post\'
, \'numberposts\' => -1
, \'post_status\' => published
);
$posts = get_posts( $args );
foreach ( $posts as $post )
{
if( \'\' == $post->post_excerpt )
{
$aioseop = get_post_meta( $post->ID, \'_aioseop_description\' ,true);
if( \'\' != $aioseop )
{
$po = array();
$po = get_post( $post->ID, \'ARRAY_A\' );
$po[\'post_excerpt\'] = $aioseop;
wp_update_post($po);
}
}
}
}
文档:
register_activation_hook
,
get_posts
,
get_post
,
wp_update_post
.