Skip to content

Instantly share code, notes, and snippets.

@billerickson

billerickson/front-page.php Secret

Last active Jul 17, 2018
Embed
What would you like to do?
<?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
You can’t perform that action at this time.