• We are getting a headache on this. We would like to add a form of date limiter to the following code so that it only shows the most popular posts from a set amount of time, IE last 7 days.

    We have included the code where we believe it needs to be changed, should anyone be able to help and require the full code please let me know. We are happy for it show most comments but it is showing posts that are far too old now.

    Many thanks in advance for all help. Theme is Technical Speech.

    function popularPosts($options='') {
    	$ns_options = array(
                        "count" => "3",
    					"comments" => "0",
                        "before"  => "<div class=\"postblock\">",
                        "after" => "</div>",
    					"show" => true,
    					"place" => "content_col"
                       );
    
    	$options = explode("&",$options);
    
    	foreach ($options as $option) {
    		$parts = explode("=",$option);
    		$options[$parts[0]] = $parts[1];
    
    	}
    
    	if ($options['count']) {$ns_options['count'] = $options['count'];}
    	if ($options['comments']) {$ns_options['comments'] = $options['comments'];}
    	if ($options['before']) {$ns_options['before'] = $options['before'];}
    	if ($options['after']) {$ns_options['after'] = $options['after'];}
    	if ($options['show']) {$ns_options['show'] = $options['show'];}
    	if ($options['place']) {$ns_options['place'] = $options['place'];}
    
    	global $wpdb;
        $posts = $wpdb->get_results("SELECT comment_count, ID, post_title, post_excerpt, post_content FROM $wpdb->posts WHERE post_type='post' AND post_status = 'publish' AND comment_count >= ".$ns_options['comments']." ORDER BY comment_count DESC LIMIT 0 , ".$ns_options['count']);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘End of tether using date codes’ is closed to new replies.