I'm having trouble with trying to make a blog listing page, I have a page in Wordpress called Blog. Within this is some written content and that's it. I'm using the following query to make it output the content of that page:
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<h2>Clever Thinking</h2>
<p><?php the_content(); ?> </p>
<?php endwhile; ?>
This all works fine. Below that, I'm trying to create a query to all my general posts, with a pagination, displays four posts per page.
<!-- Fetch blog posts -->
<?php
// The query for 4 posts
$query = new WP_Query( 'posts_per_page=4' );
// Output the results of the query
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php endwhile; ?>
<!-- end of the loop -->
<!-- pagination here -->
<?php wp_reset_postdata();
// If no results appear
else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
But this part is apparently not correct as I do not get anything, not even the posts error message, so the function is not even firing? I can't work out why this query would not work.
$the_query->the_post();
should be$query->the_post();