small mod to the get_slides function to display the most popular posts
-
Hi all,
I have made a small modification to the get_slides function (in tools.php) in order to get the most popular posts.
The default posts option gets the most recent posts (source = ‘posts: recent’) The modification allows you to select the posts with the most comments (source = ‘posts: popular’).
This is the modified code in tools.php:
// Source: posts if ( $args['source']['type'] === 'posts' ) { switch ( $args['source']['val'] ) { case 'recent': break; case 'popular': $query['orderby'] = 'comment_count DESC'; break; default: $query['post__in'] = (array) explode( ',', $args['source']['val'] ); $query['orderby'] = 'post__in'; } }
Example of its use :
[su_carousel source="<strong>posts: popular</strong>" limit="5" link="post" height="400" items="1" autoplay="3000"]
Is there any way to prevent that my modifications are overwritten by a new version of the plugin ?
Or can this be implemented in a future release ?
Thanks for any suggestions.
Effevee
- The topic ‘small mod to the get_slides function to display the most popular posts’ is closed to new replies.