showing one post form a category before regular page content
-
So I’m using this bit of code to display the content of one post from a category on my homepage.
<?php $wp_query = new WP_Query(array('posts_per_page' => 1, 'cat'=> 14 ) ); ?> <?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> <?php the_content();?> <?php endwhile; ?> <?php endif; // do not delete ?>
I’d like to use the same bit of code to display the same post above the Page content of a certain page. The loop doens’t seem to close properly and instead of showing the post content, and then the normal page content, it’s showing the post content twice:
[Code moderated as per the Forum Rules. Please use the pastebin]
What am I doing wrong?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘showing one post form a category before regular page content’ is closed to new replies.