PHP
[WP]qTranslate X Cleanup to single language
2019年4月1日<?php// qTranslate X Cleanup to single language// 1: database backup [important!!!]// 2: settings -> language ->[Import/Export] -> [Convert database to the "square bracket only" style.]check -> SaveChanges// 3: this code paste to functions.php// 4: reload your site// 5: delete this code from functions.php// 6: Remove qTranslate pluginglobal $post;$language = 'en'; // Language you want to keep$args = array( 'post_type' => array('post','page'), // Change if necessary 'post_status' => array('publish','pending','draft','auto-draft','future','private','inherit','trash'), // Change if necessary 'posts_per_page' => 9999999, 'offset' => 0, 'orderby' => 'ID', 'order' => 'ASC', 'suppress_filters' => true, 's'=> '[:]');$posts_array = get_posts( $args );foreach ( $posts_array as $post ) : setup_postdata( $post ); $post->post_content = qtrans_use($language, $post->post_content,false); $post->post_title = qtrans_use($language, $post->post_title,false); wp_update_post($post); $count++;endforeach;wp_reset_postdata();