【发布时间】:2015-06-10 11:20:39
【问题描述】:
所以我有这个自定义小部件,您可以在其中从下拉框中选择一个页面,该小部件将引导您进入该页面。问题是我不知道如何显示页面的附件图片。
wp_get_attachment_image($page, 'full') 不起作用。在法典中有一个带有循环的示例,但在这里我只需要那个图像。
// This is where you run the code and display the output
$page = $instance['selected']; ?>
<a href="<?= get_the_permalink($page); ?>">
<?php wp_get_attachment_image( $page, 'full' ); ?>
<article>
<h2><?php echo $title; ?></h2>
<h3><?php echo $instance['content']; ?></h3>
</article>
<div class="readmore">Read more</div>
</a>
<?php
echo $args['after_widget'];
}
【问题讨论】:
标签: php wordpress image widget attachment