jeudi 26 février 2015

Why is my sub-category template showing the wrong posts


I've got a problem with a custom category template. Used on sub-categories for a particular parent.


For some odd reason it's not showing posts store within it, but instead from a another sub-category.


I don't quite understand it, as the loop is the same as is used on my category.php page. The difference if the code before hand.


Here is the code:



<?php get_header(); ?>


<?php global $post; ?>
<?php
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );
?>
<div class="parallax" id="parallax1" style="background: url(<?php echo $src[0]; ?> ) !important; background-position: 50% 50% !important; background-repeat: no-repeat !important; background-size: cover; background-attachment: fixed !important;">
<div class="parallax-content">
<h1 class="page-title"><?php
printf( __( '%s', 'adventure' ), '<span>' . single_cat_title( '', false ) . '</span>' );
?></h1>
<?php
// Display optional category description
$category_description = category_description();
if ( ! empty( $category_description ) )
echo '<div class="archive-meta">' . $category_description . '</div>';
get_template_part( 'loop', 'category' );
?>
</div>
</div>

<div id="page-wrapper">

<div id="content-container">
<div class="page-content">
<!-- START THE LOOP -->
<?php $posts=query_posts($query_string . '&order=asc');
while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<?php echo catch_video() ?>

<!-- Get featured image -->
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>
<div class="post-content">

<div class="post-info top">
<span class="post-date"><?php the_date('j F, Y'); ?></span>
<span class="no-caps post-autor">by <?php the_author(); ?></span>
</div>
<h1 class="post-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<?php print_excerpt(500); ?>
<a class="read-more-btn" href="<?php the_permalink(); ?>"><?php _e( 'Read More &rarr;'); ?></a>
<div class="post-info bottom">
<span class="post-date">In: <?php the_category(', ') ?>&nbsp; <?php comments_number( 'no comments', 'one comment', '% comments' ); ?> </a>
</span>
</div>
<div class="clear"></div>

</div><!-- post content -->
</article>
<?php endwhile; ?>
<div id="blog-pagination">
<div class="alignleft"><?php previous_posts_link('«&nbsp; Previous'); ?></div>
<div class="alignright"><?php next_posts_link('Next &nbsp; »'); ?></div>
</div>
</div><!-- page content -->


</div><!-- content container -->
</div><!-- page wrapper -->

<?php get_footer(); ?>


Can anyone help me understand what is happening here. I thought it might be because there is some kind of pseudo loop used to get the category titles and description, but I tired resetting the query 'wp_reset_query();' without any success.


Thanks





Aucun commentaire:

Enregistrer un commentaire