WordPress.org

Ready to get started?Download WordPress

Forums

Today's posts from previous years - omit the current year from displaying? (6 posts)

  1. nmhall
    Member
    Posted 5 years ago #

    Hello,

    I've created a simple query to pull posts from today's date in previous years out of my db and display them on the index page.

    Unfortunately, my PHP isn't enough up to snuff to figure out how to omit the current year's post (from the current date) and prevent it from displaying. Here's the code I've got so far:

    <?php $current_day = date('d'); ?>
    <?php $current_month = date('m'); ?>
    
    <?php 
    
    //query stories from day and month variables defined above
    query_posts("monthnum=$current_month&day=$current_day&order=DESC"); 
    
    	if (have_posts()) : ?>

    Any advice? Thanks!

  2. nmhall
    Member
    Posted 5 years ago #

    bump

  3. nmhall
    Member
    Posted 5 years ago #

    Just adding a couple links for anyone else who comes across a similar problem, none of these quite offers a solution to what I'm looking for though:

    http://codex.wordpress.org/Template_Tags/query_posts#Time_Parameters

    http://wordpress.org/support/topic/267931?replies=2#post-1066144

  4. nmhall
    Member
    Posted 5 years ago #

    I've given up on this for the moment as other work comes my way, hope to be able to post a solution in the near future.

  5. gilig
    Member
    Posted 4 years ago #

    Ommiting the date
    -----------------
    It happens that if you delete this code from your post

    <?php the_time('F jS, Y') ?>

    It works in my web, http://www.sekolahku.info/
    It's just a beginner trial though. Sorry if this isn't what you're looking for.

  6. gilig
    Member
    Posted 4 years ago #

    Hi - thanks for visiting. So, what do you think?
    Is it the solution you are looking for?

Topic Closed

This topic has been closed to new replies.

About this Topic