I need 3 different queries in one page.
When I do it I get an error like this:
Cannot redeclare filter_where() (previously declared in W:\home\zerk\www\wp-content\themes ewss\most_commented.php:19) in W:\home\zerk\www\wp-content\themes ews\most_commented.php on line 41
Here is my code:
<div id="page-wrap">
<h3>Most commented </h3>
<div id="example-five">
<ul class="nav">
<li class="nav-one"><a href="#featured" class="current">Lat day</a></li>
<li class="nav-two"><a href="#core">Lat week</a></li>
<li class="nav-three"><a href="#jquerytuts">Lat month</a></li>
</ul>
<div class="list-wrap">
<ul id="featured">
<?php
function filter_where($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-1 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts('post_type=post&posts_per_page=5&orderby=comment_count&order=DESC');
while (have_posts()): the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php
endwhile;
wp_reset_query();
?>
</ul>
<ul id="core" class="hide">
<?php
function filter_where($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-7 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts('post_type=post&posts_per_page=5&orderby=comment_count&order=DESC');
while (have_posts()): the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php
endwhile;
wp_reset_query();
?>
</ul>
<ul id="jquerytuts" class="hide">
<?php
function filter_where($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts('post_type=post&posts_per_page=5&orderby=comment_count&order=DESC');
while (have_posts()): the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php
endwhile;
wp_reset_query();
?>
</ul>
</div>