Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7607755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:44:45+00:00 2026-05-31T00:44:45+00:00

I need 3 different queries in one page. When I do it I get

  • 0

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\newss\most_commented.php:19) in W:\home\zerk\www\wp-content\themes\news\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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:44:46+00:00Added an answer on May 31, 2026 at 12:44 am

    The problem is given in the error message very clearly.

    Cannot redeclare filter_where()

    You can’t re-declare the function filter_where – try this. Notice the functions are given unique names.

    • filter_where
    • filter_where2
    • filter_where3

    This is true in all PHP, you can’t have more than one function with the same name.

    <div id="page-wrap">
        <h3>Most commented </h3>
        <div id="example-five">
            <ul clas="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_where2($where = '') {
                $where .= " AND post_date > '" . date('Y-m-d', strtotime('-7 days')) . "'";
                    return $where;
                }
                    add_filter('posts_where', 'filter_where2');
                    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_where3($where = '') {
                $where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
                    return $where;
                }
                    add_filter('posts_where', 'filter_where3');
                    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>
    

    That said, the code has lots of other problems too – I would suggest reading a basic introduction to PHP.

    http://php.net/manual/en/tutorial.php

    The whole idea of a function is one of encapsulation, that is, you write the code once – then call it when you need that functionality.

    http://www.w3schools.com/php/php_functions.asp

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to make two queries on two different tables and the data isn't
I need to read different values stored in a file one by one. So
I have 2 queries which display 2 different values but the results from one
I have about 4 or 5 different queries that are all exactly like with
I've never had to use mysqli until today and cannot seem to get this
I have currently created a facebook like page that pulls notifications from different tables,
I need a different random number for each row in my table. The following
I have three different development machines. Do I need three different iPhone Developer Program
Suppose I have virtual function foo() in class B, and I need slightly different
I need to concatenate different lines in a string. To do so, I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.