我正在尝试回显包含 html 代码和 PHP 代码的混合字符串,但我尝试的所有可能的事情都没有成功。
基本上我想做的是将以下代码循环3次。每次都给我 3 个名称中带有数字递增的 div。
此代码将在 wordpress 模板中使用。
我没有回显的正常代码如下:
<div id="gallery <?php $c; ?>">
  <?php query_posts('post_type=portfolio'); ?>
  <?php if(have_posts()) : ?>
    <?php while(have_posts()) : the_post(); ?>
      <?php if ( has_post_thumbnail() ) : ?>
        <a href="<?php the_permalink(); ?>" 
           title="<?php the_title_attribute(); ?>" >
           <?php the_post_thumbnail(); ?>
        </a>
      <?php endif; ?>
      <h1><?php the_title(); ?></h1>
      <a href="<?php the_permalink(); ?>" 
         title="<?php the_title_attribute(); ?>" > 
         <h2>View Project</h2>
      </a>
      <?php the_content() ?>
    <?php endwhile; ?>
  <?php endif; ?>
</div>
我对 PHP 还很陌生,所以我不知道如何以正确的方式回应这一点。我的 for 循环已经设置好了。
我希望你们能帮助我。
亲切的问候 Dragon54