WP_Query代码在HTML中输出PHP,而不是输出结果


WP_Query code outputs the PHP in the HTML instead of results

我有一个页面,应该在某个类别中显示3个最新的帖子。使其工作的PHP代码在

下面
<section id="projects">
  <div class="container">
    <div class="row">
    <h2><span class="w200">Latest </span><span class="w600 green">Roofing Projects</span></h2>
    <p class="text-center pad_bottom">Click to view latest project</p>
      <?php //latest projects loop
      $latestProj = new WP_Query('cat=3&posts_per_page=3');
        if ($latestProj->have_posts()) :
          while ($latestProj->have_posts()) : $latestProj->the_post(); ?>

      <div class="col-lg-4">
        <?php
          if (has_post_thumbnail()) {
            the_post_thumbnail('square-thumbnail'); ?>
        <p class="proj_title"><?php the_title(); ?></p>
        <p><?php the_title(); ?></p>
      </div>
      <?php endwhile;
        else :
      endif;
    wp_reset_postdata();
    ?>
    </div>
      <p class="pad_top text-center"><a role="button" href="#" class="westbtn btn btn-lg">View Project Gallery »</a></p>
  </div>
</section>

我的页面显示的不是结果

http://www.roof.zenwebcreative.com.au/test/

我只是一个PHP初学者,我从各种来源得到了代码,这些来源都显示了编写代码的相同方式。在这件事上我将感激任何帮助。由于

我从你的评论中发现我把它放在了错误的地方。首先,我应该提到我在Wordpress上工作。我通过wp-admin将该代码包含在页面中。我应该包括在模板页,而不是。