Last active
December 24, 2015 02:19
-
-
Save hchouhan/6729311 to your computer and use it in GitHub Desktop.
OnePageMania
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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