wordpress - WP_Query code outputs the PHP in the HTML instead of results -
i have page supposed display 3 of latest posts in category. php code make work below
<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 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>
instead of results page shows following
http://www.roof.zenwebcreative.com.au/test/
i beginner php , got code various sources show same way writing code. appreciate in matter. thanks
i figured out comments including it in wrong place. firstly should have mentioned working on wordpress. including code within page through wp-admin. should including in template page instead. works now.
Comments
Post a Comment