基本上,我只想在主页上添加缩略图图像,但它也显示缩略图图像(特色图像)在单一的内容,我不想加载在单一的页面。
我想像这样添加缩略图:

(来自here )
主题:强调发展主题
我的content.php:
<?php
/**
* Template part for displaying posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package DevWP
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php
if ( is_singular() ) :
the_title( '<h1 class="entry-title">', '</h1>' );
else :
the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
endif;
if ( 'post' === get_post_type() ) :
?>
<div class="entry-meta">
<?php devwp_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif; ?>
</header><!-- .entry-header -->
<?php devwp_post_thumbnail(); ?>
<div class="entry-content">
<?php
if ( is_single() ) {
the_content( sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'devwp' ),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
) );
} else {
the_excerpt();
}
wp_link_pages( array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'devwp' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php devwp_entry_footer(); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-<?php the_ID(); ?> -->
<hr>发布于 2018-10-20 03:12:44
我不确定我是否正确理解了你的目标是什么,但如果你想只在主页上显示特色图像,而不是其他页面,那么你可以尝试两件事。在content.php文件中的第一个检查您是否在使用is_front_page()访问主页:
if(is_front_page()){
devwp_post_thumbnail();// I suppose this is echoing your thumbnail
}您可以做的第二件事是为不打算输出缩略图的页面创建自定义页面模板。
发布于 2018-10-20 14:14:07
把这个代码..。
if( is_front_page() && is_home() ) {
devwp_post_thumbnail();
}https://stackoverflow.com/questions/52898093
复制相似问题