我正在使用自定义制造的工具在WP 3.01安装中以编程方式帖子更新。有时我确实通过编程方式更改 post_status 从草稿到使用自定义出版 SELECT 查询,但是这似乎使帖子固定了。

在选秀状态时,帖子具有以下链接结构

http://myblog.com/?p=73006

是否可以有一些“技巧”来迫使链接结构发生变化,从而产生适当的永久链接?

有帮助吗?

解决方案

您需要在此操作时进行编程设置。 SQL触发器可以解决问题。不要忘记脑子在写作时重复的sl。

否则,编写一个调用WP API的PHP脚本,而不是使用数据库发布。

其他提示

创建一个 .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 要空的字段(此字段定义了Post Persalink slug),然后WordPress自动填充您的值 wp_update_post(). 。如果你想改变 post_type''post' 或者 post_type''page' 只需更改这一行:

'post_type'      => 'urun',
许可以下: CC-BY-SA归因
scroll top