“10”,
“comments” => “0”,
“before” => “
“after” => “
\n”,
“order” => “desc”,
“nofollow” => false,
“show” => true
);
$options = explode( “&”, $options );
foreach ( $options as $option ) {
$parts = explode( “=”, $option );
$ns_options[$parts[0]] = $parts[1];
}
if ( strtolower( $ns_options[‘order’] ) == “desc” ) {
$sqlorder = “ORDER BY comment_count DESC”;
}
if ( strtolower( $ns_options[‘order’] ) == “asc” ) {
$sqlorder = “ORDER BY comment_count ASC”;
}
if ( strtolower($ns_options[‘order’] ) == “rand” ) {
$sqlorder = “ORDER BY RAND()”;
}
global $wpdb;
$posts = $wpdb->get_results(”
SELECT ID
FROM ” . $wpdb->posts . ”
WHERE post_type=’post’ AND post_status = ‘publish’ AND comment_count >= ” . $ns_options[‘comments’].”
” . $sqlorder . ” LIMIT 0 , ” . $ns_options[‘count’]
);
foreach ( $posts as $post ) {
$queried_post = get_post($post->ID);
//print_r($queried_post );
$content = $queried_post->post_content;
$pattern = “/
]*> <\\/p[^>]*>/”;
$mot = preg_replace($pattern, ‘ ‘, $content);
//$mot = str_replace(‘
‘, ‘ ‘, $mot);
//$mot = str_replace(‘
‘, ‘ ‘, $mot);
$ope = strip_tags(substr($mot, 0, 400)) ;
//print_r(strip_tags($ope));
$cudate = date(“F j, Y”, strtotime($queried_post->post_date));
$popular .= “
if(get_the_post_thumbnail($post->ID, ‘thumbnail’)) {
$popular .= “
“;
} else {
$popular .= ““;
}
$popular .= “
$popular .= “
Posted on “.$cudate. ” by “.get_the_author($post->ID).”
“;
$popular .= “