Skip to content

Instantly share code, notes, and snippets.

@jackgregory
Created April 14, 2015 08:27
Show Gist options
  • Save jackgregory/f4a89feea9793242d875 to your computer and use it in GitHub Desktop.
Save jackgregory/f4a89feea9793242d875 to your computer and use it in GitHub Desktop.
Exclude pages from Jetpack top posts widget
/**
* Exclude pages from Jetpack top posts widget
*
* @param array $posts
* @param array $post_ids
* @param int $count
* @return array
*/
add_filter( 'jetpack_widget_get_top_posts', 'exclude_widget_get_top_posts', 10, 3 );
function exclude_widget_get_top_posts( $posts, $post_ids, $count ) {
$new_posts = array();
foreach( $posts as $post ) {
if( 'post' != get_post_type( $post['post_id'] ) )
continue;
$new_posts[] = $post;
}
return $new_posts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment