微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

WP All Import插件-设置永久链接页面

如何解决WP All Import插件-设置永久链接页面

由于WP All Import,我正在处理一个庞大的页面(超过70,000页)集成项目,因此我可以使用csv文件中的数据创建页面,这里的问题是我想根据的某些值设置永久链接我的CSV文件()。

Capture WP All Import

例如,我要创建URL:

website.com/destinations/UK/london
website.com/destinations/UK/london/agency1
website.com/destinations/UK/london/agency2
website.com/destinations/FR/paris
website.com/destinations/FR/paris/agency1
website.com/destinations/FR/paris/agency2

国家(英国,法国...)等于我的CSV文件中的一列 市(伦敦,巴黎...)等于我的CSV文件中的一列 代理商(agency1,agency2 ....)等于我的CSV文件中的一列

有人可以帮助我吗?

谢谢:)

解决方法

我不知道您是否可以更新整个永久链接,但是您可以使用类似以下内容(未经测试)来更新后段(post_name表中的wp_posts列):

function my_saved_post( $post_id,$xml_node,$is_update ) {

    // Retrieve the import ID.
    $import_id = ( isset( $_GET['id'] ) ? $_GET['id'] : ( isset( $_GET['import_id'] ) ? $_GET['import_id'] : 'new' ) );

    // Only run for import 8. TODO: Change this to your import ID!
    if ( $import_id == '8' ) {

        // Convert SimpleXml object to array for easier use.
        $record = json_decode( json_encode( ( array ) $xml_node ),1 );

        // verify post is not a revision
        if ( ! wp_is_post_revision( $post_id ) ) {

            // update the post slug
            wp_update_post( array(
                'ID' => $post_id,'post_name' => $record['pays'] . '/' . $record['typedelieu']
            ));
        }
    }

}
add_action( 'pmxi_saved_post','my_saved_post',10,3 );

受到documentationthis SE answer的启发。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。