Forum Replies Created

Viewing 3 replies - 31 through 33 (of 33 total)
  • Thread Starter weasello

    (@weasello)

    I just inserted into The Loop the command:

    echo($post->ID);
    echo($first_post_ID);

    And it turns out that both variables are listed as NULL, which is triggering the loop.

    Maybe I am referencing the variables incorrectly, or I’m not including a file properly?

    Thread Starter weasello

    (@weasello)

    Thanks for the tips! Very informative and I’ve learned a lot. Ran in to some trouble though.


    $querydate = date('Ymd',strtotime($provided_date));
    query_posts('m=' . $querydate . '&showposts=-1');
    $count = $wp_query->post_count - 1;
    $first_post_ID = $wp_query->posts[$count]->ID;

    That’s the code I’ve used, and with The Loop you mentioned above, it does indeed show an excerpt of EVERY post made that day. I inserted some echo commands, and it turns out that the failing line of code appears to be:

    $count = $wp_query->post_count - 1;

    This value, no matter what date is inserted, is always “-1”.

    Because of this, $first_post_ID always ends up being the same and the “if” statement is triggered for each post.

    I’m really scratching my head over this one!

    Thread Starter weasello

    (@weasello)

    That worked! For reference (future searchers):

    <?php
    require(‘./path-to-your-blog/wp-blog-header.php’);
    ?>

    That’s all you need to include the WPDB and all it’s functions. The link above (provided by Moshu) goes on to describe how to insert “the loop” into another file if you need it.

Viewing 3 replies - 31 through 33 (of 33 total)