WordPress.org

Ready to get started?Download WordPress

Forums

Limiting a loop to an amount of days (1 post)

  1. enderpal444
    Member
    Posted 2 years ago #

    I'm trying to use this filter

    <?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($query_string);
    ?>

    to limit the amount of days for posts in different loops but Im confused on how to use it on multiple different loops on one page. I add it before a loop and then remove the filter at the end of the loop but when I try to place the code before another loop and set a different amount I get an error saying "Cannot redeclare filter_where() (previously declared in ". How can I use it in multiple occurrences?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.