• Hi,

    first of all thanks to Ikki24 for this very useful plugin.

    I needed the functionality to just include specific post ids. I modified the plugins code to do so. I would very much appreciate if you could include this functionality into the plugin directly, so that i don’t have to modify each new version.

    Cu, poetter

    Here is a unified diff of the modification:

    --- D:/wordpress-popular-posts/wordpress-popular-posts.php	Wed Jul 14 18:52:38 2010
    +++ D:/wordpress-popular-posts_mod/wordpress-popular-posts.php	Mon Dec 13 19:07:37 2010
    @@ -158,6 +158,8 @@
     			$instance['post-excerpt']['keep_format'] = $new_instance['post-excerpt-format'];
     			$instance['exclude-cats']['active'] = $new_instance['exclude-cats'];
     			$instance['exclude-cats']['cats'] = empty($new_instance['excluded']) ? '' : (ctype_digit(str_replace(",", "", $new_instance['excluded']))) ? $new_instance['excluded'] : '';
    +			$instance['include-posts']['active'] = $new_instance['include-posts'];
    +			$instance['include-posts']['posts'] = empty($new_instance['included']) ? '' : (ctype_digit(str_replace(",", "", $new_instance['included']))) ? $new_instance['included'] : '';
     			if ($this->thumb) { // can create thumbnails
     				$instance['thumbnail']['active'] = $new_instance['thumbnail-active'];
     				$instance['thumbnail']['thumb_selection'] = empty($new_instance['thumb_selection']) ? "wppgenerated" : $new_instance['thumb_selection'];
    @@ -211,6 +213,10 @@
     					'active' => false,
     					'cats' => ''
     				),
    +				'include-posts' => array(
    +					'active' => false,
    +					'posts' => ''
    +				),
     				'thumbnail' => array(
     					'active' => false,
     					'width' => 15,
    @@ -602,8 +608,13 @@
     			} else {
     				$exclude = "";
     			}
    -
    -			$mostpopular = $wpdb->get_results("SELECT $wpdb->posts.ID, $wpdb->posts.post_title $fields FROM $wpdb->posts $join WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_password = '' AND $range $force_pv $nopages $exclude GROUP BY $wpdb->posts.ID ORDER BY $sortby DESC LIMIT " . $instance['limit'] . "");
    +
    +			if ( $instance['include-posts']['active'] && !empty($instance['include-posts']['posts']) ) {
    +				$include = " AND $wpdb->posts.ID IN (". $instance['include-posts']['posts']. ")";
    +			} else {
    +				$include = "";
    +			}
    +			$mostpopular = $wpdb->get_results("SELECT $wpdb->posts.ID, $wpdb->posts.post_title $fields FROM $wpdb->posts $join WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_password = '' AND $range $force_pv $nopages $exclude $include GROUP BY $wpdb->posts.ID ORDER BY $sortby DESC LIMIT " . $instance['limit'] . "");
    
     			$content = '';
    
    @@ -1000,6 +1011,7 @@
     				'excerpt_length' => 0,
     				'excerpt_format' => 0,
     				'cats_to_exclude' => '',
    +				'posts_to_include' => '',
     				'thumbnail_width' => 0,
     				'thumbnail_height' => 0,
     				'thumbnail_selection' => 'wppgenerated',
    @@ -1042,6 +1054,10 @@
     				'exclude-cats' => array(
     					'active' => empty($cats_to_exclude) ? false : (ctype_digit(str_replace(",", "", $cats_to_exclude))) ? true : false,
     					'cats' => empty($cats_to_exclude) ? '' : (ctype_digit(str_replace(",", "", $cats_to_exclude))) ? $cats_to_exclude : ''
    +				),
    +				'include-posts' => array(
    +					'active' => empty($posts_to_include) ? false : (ctype_digit(str_replace(",", "", $posts_to_include))) ? true : false,
    +					'posts' => empty($posts_to_include) ? '' : (ctype_digit(str_replace(",", "", $posts_to_include))) ? $posts_to_include : ''
     				),
     				'thumbnail' => array(
     					'active' => empty($thumbnail_width) ? false : (is_numeric($thumbnail_width)) ? (($thumbnail_width > 0) ? true : false) : false,

The topic ‘[Plugin: WordPress Popular Posts] Suggestion: include_posts parameter’ is closed to new replies.