-
-
Save billerickson/2f3e532474f8a57f3a4968d2d2947817 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Featured Posts | |
* Display 5 posts from the "featured posts" category, published in the | |
* last 2 weeks, sorted by share count. | |
*/ | |
function ea_featured_posts() { | |
$loop = get_transient( 'ea_featured_posts' ); | |
if( false === $loop ) { | |
$loop = new WP_Query( array( | |
'posts_per_page' => 5, | |
'category_name' => 'featured-posts', | |
'orderby' => 'meta_value_num', | |
'meta_key' => 'shared_counts_total', | |
'order' => 'DESC', | |
'date_query' => array( array( 'after' => '2 weeks ago' ) ) | |
) ); | |
set_transient( 'ea_featured_posts', $loop, DAY_IN_SECONDS ); | |
} | |
// ... | |
} | |
add_action( 'genesis_before_loop', 'ea_featured_posts' ); | |
// Build the page | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment