Wordpress 功能-如何将图像附加到帖子?

Wordpress 功能-如何将图像附加到帖子?,wordpress,Wordpress,我计划使用一个滑块,它使用短代码: [su_carousel source="media: 160,161,162" limit="10" link="image" height="300" title="no"] 此160161162是附加到该帖子的图像ID。 因此,我需要一些自动功能,可以给我与附加到post的图像ID数组 我正在使用wpallimport插件,我需要为所有帖子构建模板,现在我可以导入所有与帖子相关的图片,但没有一个函数允许我获取图片ID 有什么帮助吗?您可以使用get\u

我计划使用一个滑块,它使用短代码:

[su_carousel source="media: 160,161,162" limit="10" link="image" height="300" title="no"]
160161162
是附加到该帖子的图像ID。 因此,我需要一些自动功能,可以给我与附加到post的图像ID数组

我正在使用wpallimport插件,我需要为所有帖子构建模板,现在我可以导入所有与帖子相关的图片,但没有一个函数允许我获取图片ID

有什么帮助吗?

您可以使用get\u posts():


谢谢你的回答。我试着把这个代码放到我的帖子里,但它什么也没显示出来。。。(为了在帖子中使用PHP,我使用插件PHP帖子)。这是完整的代码吗?请与我联系以获取更多信息,我在上向您发送了电子邮件info@seopex.netPls再次发送邮件。ThxI回复您的电子邮件,但尚未收到您的任何回复。
$args = array( 
    'post_type' => 'attachment', 
    'posts_per_page' => -1, 
    'post_status' =>'any', 
    'post_parent' => $post->ID
); 
$attachments = get_posts( $args );
if ( $attachments ) {
    foreach ( $attachments as $attachment ) {
        $attachments_ids_array[] = $attachment->ID;
    }
}

$attachments_ids = implode (", ", $attachments_ids_array)