PHP WordPress - 如何用图像替换粘性帖子中的“特色”文本


PHP WordPress - How to replace with image the "Featured" text in sticky post?

我正在使用 Twenty-Sixteen 主题作为子主题,我想删除粘性帖子下的"精选"文本行,并将其替换为同一位置的图像。

我试图通过删除内容中的文本块来编辑它'Featured'.php但是当我预览页面时,一切都消失了。

你怎么看,我该怎么办?提前谢谢。

我想

我找到了解决方案。

这:

<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
            <span class="sticky-post"><a href="<?php _e( 'javascript:void(0)', 'twentysixteen' ); ?>" rel="home"><img src="/sticky_pin.png"> </a></span>
        <?php endif; ?>

取而代之的是:

<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?> 
            <span class="sticky-post"><?php _e( 'Featured', 'twentysixteen' );></span> 
            <?php endif; ?> 

肯定会起作用!

$(document).ready(function(){
  $('span.sticky-post').hide();
});

<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?> <span class="sticky-post"><?php // _e( 'Featured', 'twentysixteen' ); ?></span> <?php endif; ?>

<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?> <span class="sticky-post" style="display:none"><?php _e( 'Featured', 'twentysixteen' ); ?></span> <?php endif; ?>