424-385-6727 nityahoyos@gmail.com Get in Touch

Loop through WordPress Posts


Because you’re on a page, that’s only going to display the query for that page. As such, you’d have to create a new query to bring in the posts you want. Replace your loop with this:

<?php
    $args = array(
        'post_type' => 'post'
    );

    $post_query = new WP_Query($args);
if($post_query->have_posts() ) {
  while($post_query->have_posts() ) {
    $post_query->the_post();
    ?>
    <h2><?php the_title(); ?></h2>
    <?php
  }
}
?>
Back to Top