【问题标题】:Show post thumbnail linstead of place holder显示帖子缩略图而不是占位符
【发布时间】:2017-11-10 14:36:09
【问题描述】:

我想将帖子缩略图添加到跨度中,但我不确定如何做到这一点,这是我尝试实现以下目标的最佳方法

<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                        <div class="single_service_item">
                            <div class="service_icon transition3s">
                                <div class="icon_border">
                                <?php the_post_thumbnail();?>
                                    <span  style=" background-image: url("/wp-content/uploads/2016/05/chrome_2017-11-09_10-46-33.png");"></span>
                                </div>
                            </div>
                            <div class="service_text">
                                <h5><?php the_title();?></h5>
                                <p><?php the_content();?></p>
                            </div>
                        </div>
                    </div>


但下面是它的风格

您可以在此处查看该网站http://ubtanz.solitudesoftware.co.uk/ 它是我想用帖子缩略图图像替换的圆形图像

【问题讨论】:

  • icon_border 类的边距有问题。
  • @VisualBean 谢谢我明白了

标签: php html wordpress wordpress-theming


【解决方案1】:

您可以使用get_the_post_thumbnail_url() 获取帖子缩略图网址。

<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
        <div class="single_service_item">
            <div class="service_icon transition3s">
                <div class="icon_border">
                    <span style="background-image: url('<?php echo get_the_post_thumbnail_url(get_the_ID(), 'full'); ?>');"></span>
                </div>
            </div>
            <div class="service_text">
                <h5><?php the_title(); ?></h5>
                <p><?php the_content(); ?></p>
            </div>
        </div>
    </div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-02
    • 2013-07-02
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 2016-06-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多