I have a question which I am sure has been asked several times, but I cannot find this on Google.
I have a loop using WP_Query, but I know I can also use get_posts. My code below uses $posts->have_posts() for the loop, but I don't think I should have to use a loop to get just one post.
How can I add the below code without the $posts->have_posts() loop in my theme? is there an array I can use instead like $posts?
$posts = new WP_Query(array( 'post_type' => 'home_page_highlights', 'posts_per_page' => 1, 'meta_key' => 'sort', 'meta_value' => $sort, )); while ( $posts->have_posts() ) : $posts->the_post(); echo "<h1>" . get_the_title() . "</h1>"; echo "<p>" . the_content() . "</p>"; endwhile;
[please mark any posted code - http://codex.wordpress.org/Forum_Welcome#Posting_Code ]