Show sticky posts first in call to WP_Query for a specific category
-
On the footer of the homepage, I wrote a query to pull in recent posts categorized as ‘news’ and only show 4.
What I would like to do now is pull back posts categorized as ‘news’ and show those marked as sticky before the others.
Here is what I have. Can you tell me how I could change it to pull in sticky posts above those that are not marked as sticky?
function get_recent_posts_front(){ $args = array( 'post_type' => 'post', 'posts_per_page' => 4, 'orderby' => 'date', 'order' => 'DESC', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => 'news' ) )); $query = new WP_Query($args); if(!$query->have_posts()) return false; $cards = array(); while($query->have_posts()): $query->the_post(); $cards[] = get_media_card($query->post); endwhile; return $cards; }
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Show sticky posts first in call to WP_Query for a specific category’ is closed to new replies.