有人可以告诉我这些功能图片在博客页面上的显示方式。我已经在index.php中嵌入了我的博客并且经历了各种论坛,但无法使图像显示出来。我使用以下代码 -
<div id="main" >
<section class="feature-image feature-image-default-alt" >
<h1 class="page-title">Blog</h1>
</section>
<!-- BLOG CONTENT
================================================== -->
<div class="container">
<div class="row" id="primary">
<main id="content" class="col-sm-8" role="main">
<?php
if ( have_posts() ) :
if ( is_home() && ! is_front_page() ) : ?>
<header>
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
</header>
<?php
endif;
/* Start the Loop */
while ( have_posts() ) : the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', get_post_format() );
endwhile;
the_posts_navigation();
else :
get_template_part( 'template-parts/content', 'none' );
endif; ?>
</main><!--content-->
<!-- SIDEBAR
================================================== -->
<aside class="col-sm-4 asidebar">
<?php get_sidebar();?>
</aside>
</div><!--primary-->
</div><!--container-->
答案 0 :(得分:1)
Wordpress具有以下功能:
while ( have_posts() ) : the_post();
$featured_img_url = get_the_post_thumbnail_url();
echo '<img src="'.$featured_img_url.'">';
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/