我正在整理我自己的WordPress主题。到目前为止,我一直在用单曲。php文件作为我的博客和媒体文件的模板。关于我的媒体文件,我一直在使用<?php the_content(); ?>
标记以调用此类图像。
我现在已经到了创建“附件”的阶段。各种媒体文件的php文件。我注意到<?php the_content(); ?>
在所述文件中不起作用,不像在“single”中。php文件。
相关替代方案是什么<?php the_content(); ?>
当涉及到调用“附件”中的图像时。php文件?
SO网友:filipecsweb
使命感the_content
从附件中。php将为您提供附件描述。
将下面的代码放在您的页面上,看看您可以从附件中获得什么。php文件:
while ( have_posts() ) : the_post();
/**
* @link https://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata#Related
*/
$data = array(
get_the_ID(), // Gets att ID.
get_permalink(), // Gets att page link.
get_the_title(), // Gets att title.
get_the_content(), // Gets att description.
wp_get_attachment_metadata(), // Gets att metadata.
);
var_dump( $data );
endwhile;
另外,您可能想看看
https://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata#Related 并查看其他可能对您有用的功能。