我想在wordpress中使用标题作为标签.有没有办法自动化这个过程,而不是一个接一个地复制和粘贴


I want to use post title as tag in wordpress. Is there anyway to automate the process instead of copy and paste one by one?

我有1k的Wordpress帖子,我想使用帖子标题作为标签。有没有办法自动化这个过程,而不是一个接一个地复制和粘贴?

使用下面的代码

add_action( 'init', 'default_function' );
function default_function() {
$args = array(
    'posts_per_page'   => -1,
    'offset'           => 0,
    'category'         => '',
    'category_name'    => '',
    'orderby'          => 'date',
    'order'            => 'DESC',
    'include'          => '',
    'exclude'          => '',
    'meta_key'         => '',
    'meta_value'       => '',
    'post_type'        => 'post',
    'post_mime_type'   => '',
    'post_parent'      => '',
    'author'       => '',
    'author_name'      => '',
    'post_status'      => 'publish',
    'suppress_filters' => true
);
$posts_array = get_posts( $args );

    foreach ($posts_array as $current_post) {
        $post_id = $current_post->ID;
        $post_title = $current_post->post_title;
        wp_set_post_tags( $post_id, $post_title, true );
    }

}

在functions.php文件中添加以上代码

请确保你只需要执行一次,然后从你的functions.php文件中删除它。然而,我在wp_set_post_tags中设置了'true'作为第三个参数,它将为特定的帖子添加标签。

是你可以在wordpress上自动发布博客文章。在这里你可以找到你的解决方案
Wordpress自动海报