Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Display 1 latest Post and 5 Featured Pages
- function sk_home_featured() {
- // WP_Query arguments
- $args1 = array (
- 'post_type' => 'post',
- 'posts_per_page' => '1',
- );
- // WP_Query arguments
- $args2 = array (
- 'post_type' => 'page',
- 'posts_per_page' => '5',
- 'meta_query' => array(
- array(
- 'key' => 'featured_page',
- 'value' => '1',
- 'compare' => '=='
- )
- ),
- );
- // The Query
- $query1 = new WP_Query( $args1 );
- $query2 = new WP_Query( $args2 );
- // create new empty query and populate it with the other two
- $wp_query = new WP_Query();
- $wp_query->posts = array_merge( $query1->posts, $query2->posts );
- // populate post_count count for the loop to work correctly
- $wp_query->post_count = $query1->post_count + $query2->post_count;
- // The Loop
- if ( $wp_query->have_posts() ) {
- echo '<div class="home-featured">';
- while ( $wp_query->have_posts() ) {
- $wp_query->the_post();
- echo '<div class="featured-item">';
- $image = genesis_get_image( 'format=url&size=home-featured' );
- printf( '<a href="%s" rel="bookmark"><img src="%s" alt="%s" /><h2 class="entry-title">%s</h2></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ), get_the_title() );
- echo '</div>';
- }
- echo '</div>';
- } else {
- // no posts found
- }
- // Restore original Post Data
- wp_reset_postdata();
- }
Add Comment
Please, Sign In to add comment