Forum Replies Created

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter web-girl

    (@web-girl)

    Sorry, just saw your follow-up post and will try that now.

    Thread Starter web-girl

    (@web-girl)

    Hi Oleg,

    Thanks for helping me, as well. Sorry, but how should I modify the code? I understand to replace the variables with the ones I’ve suggested, but how should I modify the loop?

    Here’s what I’ve changed so far:

    <?php
    global $post;
    $args = array('category' => 9, 'numberposts' => 4,'orderby' => 'date','order' => 'ASC',);
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    <?php
    $postDate = strtotime( $post->post_date );
    $todaysDate = time();
    if ( $postDate > $todaysDate | $postDate = $todaysDate) : ?>
        <li><a href="<?php the_permalink(); ?>" style="font-size:11px;"><span style="font-weight:bold;color:#afaca5"><?php the_time('n/j'); ?>:</span> <?php the_title_attribute(); ?></a></li>
    <?php endif; ?>
    <?php endforeach; ?>
    </ul>
    <br />

    Should I remove this line?:

    if ( $postDate > $todaysDate | $postDate = $todaysDate) : ?>

    Right now, when I run the modified code with the new variables, nothing is showing up in the sidebar box – is there a syntax error someplace? Thanks for helping me – I’m not very clear about how to do this.

    Thread Starter web-girl

    (@web-girl)

    Looking up mktime() led me to this in the Codex: https://codex.www.ads-software.com/Function_Reference/current_time

    If I change the variables to

    $postDate = get_the_date();
    $todaysDate = current_time('mysql');

    And echo these two variables, it outputs the same for each.

    I’m still not sure how to make this work with my code (working with dates confuses me!).

Viewing 3 replies - 16 through 18 (of 18 total)