I'm really new to WordPress and having a problem with my page template and a sidebar loop. I made a block that displays posts in a category in the sidebar, it also displays a custom field below the title of each post and the code looks like this:
<?php $published = get_post_meta( $post->ID, 'article_Details', true ); ?>
<div id="sidebar">
<div id="latest">
<h2>Recent Articles</h2>
<?php
$catquery = new WP_Query( 'cat=2&posts_per_page=6' );
while($catquery->have_posts()) : $catquery->the_post();
?>
<a class="listing" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<p class="pubdetails"><?php echo $published[0]['publication-details']; ?></p>
<?php endwhile; ?>
</div></div>
It gets displayed properly on single posts, categories and homepage but for every page on the site where it should be, it breaks, only the first item in the block gets displayed without the custom field and the foooter of the site never appears.
The template I use for my pages looks like this:
<?php get_header(); ?>
<div id="main">
<?php while (have_posts()) : the_post(); ?>
<article <?php post_class(); ?>>
<header class="entry-header">
<h1 class="entry-title"><?php the_title(); ?></h1>
</header>
<div class="entry-content">
<?php the_content(); ?>
</div>
</article>
</div>
<?php endwhile; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
I'm not sure what the issue is, I've tried changing several things to fix the code in both the page template and the sidebar template without any luck so far.