WordPress获取附件URL函数:wp_get_attachment_url

WordPress函数wp_get_attachment_url用于获取附件的URL。

wp_get_attachment_url( int $attachment_id )

函数参数

$attachment_id

整数

附件的ID

函数返回值

wp_get_attachment_url()函数返回指定附件的URL地址。

函数使用示例

if(have_posts() ) : while ( have_posts()) : the_post();
    if(has_post_thumbnail()) {
        $feat_image_url = wp_get_attachment_url(get_post_thumbnail_id());
        echo '
'; } endwhile; endif;

扩展阅读

wp_get_attachment_url()函数位于:wp-includes/post.php

相关函数:

  • wp_get_upload_dir()
  • wp_get_attachment_relative_path()
  • wp_basename()

原创文章,作者:,如若转载,请注明出处:https://ce.771633.xyz/2223.html

Like (0)
Previous 2025年3月8日
Next 2025年3月8日

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注