【发布时间】:2020-07-02 17:16:40
【问题描述】:
我的 WordPress 网站上有三种类型的帖子(标准、旁白、视频)。
我需要在我的标准content.php 文件中计算像$row 这样的变量但我无法将它传递给content.php 文件。
我的index.php文件代码:
<?php if (have_posts()) :
$$row = 2;
while (have_posts()) : the_post();
get_template_part('content', get_post_format());
$row++;
endwhile;
endif; ?>
我的content.php文件代码:
<div>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><?php the_content(); ?>- <?php echo $row; ?></p>
</div>
但是当我echo $row; 什么都没有显示
我已经使用此链接from a similar question on stackoverflow,但我无法更改我的帖子格式文件,还有其他方法吗?
【问题讨论】:
标签: php wordpress wordpress-theming