WordPress.org

Ready to get started?Download WordPress

Forums

Edit Image.php to Display Text Only From Certain Date (2 posts)

  1. evilbeet
    Member
    Posted 6 years ago #

    Hi all,

    I need some help coming up with a code snippet that I could insert into the image.php file so that a certain text will display below the image if the image was uploaded after a certain date.

    In pseudocode, this is what I want:

    If (image was posted before March 1, 2008)
    print below image: "This is my text"
    End If

    I don't know the WordPress codex well enough to figure it out on my own. Any help much appreciated!!!!

    Thanks!!!

  2. evilbeet
    Member
    Posted 6 years ago #

    Dammit, when you guys don't respond to me asap, you force me to actually solve problems for myself, which is both frustrating and time-consuming.

    :)

    This seemed to work, in case anyone else has the same question:

    <?php

    $u_time = get_the_time('U');

    if ($u_time < 1204347600)
    {?>

    This is my text

    <?php
    }

    ?>

    Where the u_time value is set to be less than the Unix Epoch time for March 1, 2008.

    If anyone has a more efficient way to do it, I'm open to suggestions.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags