I am completely not sure if I am just being blind but not 100% used to wordpress as yet and would love some assistance with this.
I have my blog posts page showing all the blog posts it also has the categories in the sidebar but when a category is selected it changes the URI with the /categories/events but does not limit the posts content to what should be in the category?
<?php get_header(); ?>
<div class="container posts">
<div class="row">
<div class="col-xs-8 col-md-8">
<?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();
?>
<div class="post">
<?php
the_post_thumbnail( 'large' );
echo '<a href="' . get_permalink() . '">';
the_title('<h2>', '</h2>');
echo '</a>';
the_excerpt();
echo do_shortcode( "[icon name='fa-calendar-o']" ) . " ";
the_date("d F");
?>
</div>
<?php
}
?>
</div>
<div class="col-xs-4 col-md-4">
<?php get_sidebar(); ?>
</div>
</div>
</div>
Any ideas? This is a full custom WP Theme from start to finish so I may be missing something very simple and if someone knows what that is I would greatly appreciate it.
WP_Queryobject that retrieves all posts. This is not the typical way of doing things, which would be simply to use the existingWP_Queryobject that's been set up by WordPress and would have the right parameters to retrieve a Category's posts on a Category page... What's the filename of the template page you've posted? - Matt GibsonWP_Queryobject, you should be able to just get rid of your$post_queryobject completely and use rawhave_posts()/the_post()calls as explained in the The Loop documentation. WordPress will use an existing query object that's already been set up appropriately for the kind of page you're displaying, based on its URL/parameters. - Matt Gibson