WordPress.org

Ready to get started?Download WordPress

Forums

Show todays post only (4 posts)

  1. striff
    Member
    Posted 3 years ago #

    Hello people!

    I hope that you understand my english...

    I want to know if there is any way to make a page where posts are listed as a blog category, but for a specific category and ONLY for current day.

    I'm asking this here because i don't want the latest posts (they may be in future scheduled), but the current day posts, in the specific category(http://www.datz.ro/category/events/).

    So... new page menu with posts from category events posted with todays current date.

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

  3. striff
    Member
    Posted 3 years ago #

    no way man... for me it's very difficult.

    Can you just paste the exact code for:
    a page-template.php that will query the posts from current day from my post category named events.

    Please help.

    Thank you!

  4. alchymyth
    Forum Moderator
    Posted 3 years ago #

    as a starting point, can you paste the code of category.php of your theme into a http://pastebin.com/ and post the link to it here?

    (or archive.php if category.php does not exist)
    that way, the new template will fit the existing html structure of your theme.

    general - add a custom query before the loop:

    <?php $today = getdate();
    $args = array(
    'category_name' => 'events',
    'posts_per_page' => -1,
    'year' => $today["year"],
    'monthnum' => $today["mon"],
    'day' => $today["mday"]
    );
    query_posts( $args );
    
    //existing loop starts here: ?>
    <?php if(have_posts()) : while(have_posts()) : the_post();

Topic Closed

This topic has been closed to new replies.

About this Topic