来自外部URL的精选图片无法正常工作

贸易情报局

我正在尝试使用外部图像作为wordpress中的特色图像。一切都正确完成,但是只有一个问题。实际的外部图像仅在通过WP管理员设置了任何特色图像时显示。我不想设置任何特色图片,但仍然希望通过该外部网址(通过自定义字段设置)中的特色图片。

我希望你们明白了。这是我的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 -->

谢谢 :)

奥马尔·塔里克(Omar Tariq)

试试这个:-

<article <?php post_class('single-entry clearfix'); ?>>   
    <div class="single-entry-thumbnail view view-first">
    <?php $custom_featured_image_url = get_post_meta($post->ID, "external_featured", true); ?>
       <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $custom_featured_image_url; aq_resize( $custom_featured_image_url,  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 -->
</article><!-- /single-entry -->

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章