Skip to content

Instantly share code, notes, and snippets.

@hchouhan
Last active December 24, 2015 02:19
Show Gist options
  • Save hchouhan/6729311 to your computer and use it in GitHub Desktop.
Save hchouhan/6729311 to your computer and use it in GitHub Desktop.
OnePageMania
<?php
$query_top_10_posts = new WP_Query(
array(
'post_type' => array( 'post' ),
'post_status' => 'publish',
'orderby' => 'meta_value_num',
'meta_key' => '_recommended',
'posts_per_page' => 10,
'nopaging' => false
)
);
// Run the loop as normal
if ( $query_top_10_posts->have_posts() ) :
while ( $query_top_10_posts->have_posts() ) : $query_top_10_posts->the_post();
$recommended = get_post_meta( $post->ID, '_recommended', true );
?>
<p>
<?php the_title() ?> - <?php echo $recommended; ?>
</p>
<?php if ( has_post_thumbnail()) { ?>
<div class="post-media">
<a class="featured-image" href="<?php the_permalink(); ?>" title="<?php printf(__('Open %s', 'dot'), get_the_title()); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
</div>
<?php } ?>
<?php
endwhile;
else:
// no posts found
endif;
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment