我试图在主页上显示数字后序排名,但是,我使用的是template\\u部件,不知道当html与wordpress循环分离时如何做到这一点。
以下是我想看到的:
这是我的循环index.php
<div class="most-recent-feed">
<?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;
$post_ranking = 1;
/* Start the Loop */
while ( have_posts() ) : the_post();
?> <h1> <?php echo $post_ranking ?> </h1> <?php
/*
* 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;
wp_reset_query();
?>
</div>
这是我的相关htmltemplate_parts/content.php
(请注意排名编号的注释:<div class="album-dark-overlay play">
<div class="ranking-triangle">
<!-- Ranking number should be placed here -->
</div>
<div id="<?php echo $youtube_id ?>" data-youtube-id="<?php echo $youtube_id ?>" class="media-circle">
<i class="icon ion-ios-play"></i><i class="icon ion-pause"></i>
</div>
</div>