• Hello,
    I’m trying to figure out on how to link in a post to posts in a certain date range!

    If found the following in the function reference:

    <?php
    //Create a new filtering function that will add our where clause to the query
    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;
    }
    // Register the filtering function
    add_filter(‘posts_where’, ‘filter_where’);
    // Perform the query, the filter will be applied automatically
    query_posts($query_string);
    ?>

    If I insert this into a post nothing is retrieved, the code just partialy show in the post.

    What I’m doing wrong?

    Thanks for any hints or help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • That code needs to go in the template file which is showing the posts.

    Thread Starter deekee

    (@deekee)

    Thanks for your reply, but I quite don’t understand!

    Why do I’ve to modify the template and therefore all the other post using this template would be affected.

    Sorry, for asking such a stupid question but I’m pretty new (< 3 weeks)
    to WP and haven’t completely understood the concept of WP yet…

    Thanks anyway and have a look what I’m trying to do in general:

    Converting http://www.1×1.indien.org into http://www.deiopea.ch/1×1 which later on should be the new website of our family runned charity organisation.

    I think I am the one who does not understand.

    Do you want:

    1. To show a page of posts within a certain date range? This is what I thought you wanted.
    2. Or, do you want to have one post on the page show titles or content from other posts in a date range with all other posts on the page remaining unchanged?
    3. Or is it something else entirely?

    Code inside posts is not usually executed, only code in templates. You can install a plugin such as Exec-PHP, but that involves disabling the Visual editor in WordPress.

    Thread Starter deekee

    (@deekee)

    You understood correctly!

    I want to:

    To show a page of posts within a certain date range? And I want to achive this by clicking on a link in another post.

    I think I will have to first read a bit more in the codex…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to link to posts in a certain date range’ is closed to new replies.