• hello
    Newbie on WP, i’d like to undestand some rules:
    i got a page (in my menu) that must displays posts to come (from today)
    i created a page and aplly it a template that i created.
    in my template.php, just before if (have_posts()) : while (have_posts()) : the_post();
    i put add_filter and query_post mbut doesn’t work…

    is it the good way to do that ?
    thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Depends. Did you look at some of the arguments you can use with query_posts/new WP_Query?

    query_posts()

    Thread Starter pipoulito

    (@pipoulito)

    actually in query_post, in can’t have operators like “>” only “=” so i can’t have post with date>today…am i wrong ?

    If it is date range your are looking at, then follow the link provide above (query_posts) and look at the examples in the Time parameters section.

    Thread Starter pipoulito

    (@pipoulito)

    that’s the problem, that’s what i’ve done but this works:
    query_posts(‘category_name=test&monthnum=03’);
    if ( have_posts() ) : while ( have_posts() ) : the_post();

    BUT NOT THIS (is is a syntax problem ?):
    function filter_where($where = ”) {
    //posts for March 1 to March 15, 2009
    $where .= ” AND post_date >= ‘2009-03-01’ AND post_date < ‘2009-03-16′”;
    return $where;
    }
    add_filter(‘posts_where’, ‘filter_where’);
    query_posts($query_string);
    if ( have_posts() ) : while ( have_posts() ) : the_post();

    thanks a lot!!!!

    I’m not somewhere I can test this code, but I would try something like:

    $where .= " AND (wp_posts.post_date >= '2009-03-01') AND (wp_posts.post_date < '2009-03-16')";

    …where wp_posts is the name of your WordPress Posts table.

    Thread Starter pipoulito

    (@pipoulito)

    thanks but i’ve still “not found” with this…
    $query_string seems to be url of page ? it should be parameters of a query, should not it ?

    i’ve been running into a similar issue for the past few days and i get really confused

    to me it seems that

    add_filter(‘posts_where’, ‘filter_where’);
    doesn’t apply to
    query_posts($query_string);
    where $query_string would be a part of a larger MySql query

    it only works with query_posts using the url like structure; but with the url like structure there’s no possibility to establish a date range
    so maybe there’s another filter to be used that would affect the query at the right place/moment…

    pipoulito: did you get any chance overcoming this problem?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘add_filter query_post’ is closed to new replies.