【发布时间】:2014-01-20 07:04:47
【问题描述】:
我正在尝试使用外部图片作为 wordpress 中的特色图片。一切都正确完成,但只有一个问题。仅当通过 WP 管理员设置了任何特色图像时,才会显示实际的外部图像。我不想设置任何特色图片,但仍希望通过自定义字段设置的外部 URL 中的特色图片。
我希望你们明白了。这是我的 content.php 的代码,外部特色图片由get_post_meta($post->ID, "external_featured", true);触发
<article <?php post_class('single-entry clearfix'); ?>>
<?php if( has_post_thumbnail() ) { ?>
<div class="single-entry-thumbnail view view-first">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo get_post_meta($post->ID, "external_featured", true); aq_resize( wp_get_attachment_url( get_post_thumbnail_id(), 'full' ), wpex_img( 'blog_entry_width' ), wpex_img( 'blog_entry_height' ), wpex_img( 'blog_entry_crop' ) ); ?>" alt="<?php echo the_title(); ?>" /></a>
<div class="mask">
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<p>
<?php
if( !empty($post->post_excerpt) ) {
the_excerpt();
} else {
echo wp_trim_words(get_the_content(), 20); }
?>
</p>
<a href="<?php the_permalink(); ?>" class="info">Download</a>
</div>
</div><!-- /single-entry-thumbnail -->
<?php } ?>
</article><!-- /single-entry -->
谢谢你:)
【问题讨论】:
标签: php wordpress custom-fields