Php 设置';post#U格式';WordPress

Php 设置';post#U格式';WordPress,php,wordpress,Php,Wordpress,目前,我的自动过帐流程文件有以下代码 // Create post object $my_post = array( 'post_title' => wp_strip_all_tags( trim( $row['title'] ) ), 'post_content' => $content, 'post_format' => 'audio', 'post_status' => 'p

目前,我的自动过帐流程文件有以下代码

// Create post object
$my_post = array(
          'post_title'    => wp_strip_all_tags( trim( $row['title'] ) ),
          'post_content'  => $content,
          'post_format' => 'audio',
          'post_status'   => 'publish',
          'post_author'   => 1,
          'post_category' => array( 2 ),
          'post_date' => date('Y-m-d H:i:s')
);
您可以在上面看到,我在数组中包含了
'post_format'=>“audio',
,但这似乎并没有将现有的post格式从“标准”设置为“audio”,这正是我试图实现的

现在我开始在这里取得一些进展,但我仍然被扔到了死胡同里

set_post_format($post->ID, 'audio' );
如果我把它添加到我的循环中,在编辑我的帖子时,它实际上会将格式更改为音频,但我必须手动编辑帖子,以使其更改,这是一个问题

<?php       
    while ( have_posts() ) : the_post();
    set_post_format($post->ID, 'audio' );

        get_template_part( 'template-parts/content', get_post_format() );

        // If comments are open or we have at least one comment, load up the comment template.
        if ( comments_open() || get_comments_number() ) :
            comments_template();
        endif;
    endwhile; // End of the loop.
?>


以上是我的循环,在这一点上,真诚地感谢任何帮助。。我正在努力解决这个问题,希望知道如何自动设置它,以便每次上传时我的
post\u格式都默认为“audio”。

我想你想要的是
set\u post\u format()

可能的重复: