创建一个.php
在WordPress目录的根目录中创建文件并写入:
<?php
require( \'wp-load.php\' );
$urunler = array(
\'order\' => \'ASC\',
\'post_type\' => \'urun\',
\'post_status\' => null,
\'numberposts\' => -1,
);
$tumurunler = get_posts($urunler);
if ($tumurunler) {
foreach ($tumurunler as $urun) {
$urun->post_name = \'\';
wp_update_post( $urun ); // Update the post into the database
}
}
所以这段代码会加载
post_type==\'urun\'
并设置
$urun->post_name
字段为空(此字段定义后permalink段塞),然后在调用时WordPress会自动为您填充一个值
wp_update_post()
. 如果你想改变
post_type\'
到
\'post\'
或
post_type\'
到
\'page\'
只需更改此行:
\'post_type\' => \'urun\',