Displaying 2 features posts
-
Hi there,
I am trying to display the latest post from a specific category as a featured post.
I have this code:
<?php $category_id = get_cat_ID( 'Competitions' ); $args = array( 'cat' => $category_id, 'post__in' => get_option('sticky_posts'), ); ?> <?php $the_query = new WP_Query($args); $the_query = new WP_Query( 'posts_per_page=1' );?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
which is supposed to get the post from the post category “Competitions”
This works fine, except when I add the same code and change the category to “Interviews”, both blocks then display the same post from “Interviews”
<?php $category_id = get_cat_ID( 'Interviews' ); $args = array( 'cat' => $category_id, 'post__in' => get_option('sticky_posts'), ); ?> <?php $the_query = new WP_Query($args); $the_query = new WP_Query( 'posts_per_page=1' );?> <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
Can anyone see what I am doing wrong with my code?
Thanks!
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Displaying 2 features posts’ is closed to new replies.