put the_date in ul with format in li's (7 posts)

  1. lokjah
    Posted 11 years ago #

    hi there, i'm trying to tweak the_date and wrap it in a ul but my script doesnt seem to work

    //parse date to list
    $mydate = the_date("M.d.y");
    print("<ul class=\"datelist\">n");
    $tok = strtok($mydate, ".");

    $the_dateloopnum = 1;
    while ($tok) {

    $dateclass = "month";
    $dateclass = "day";
    $dateclass = "year";

    print("<li class=\"$dateclass\">$tok</li>n");
    //below closes date token
    $tok = strtok(".");

    it outputs the date outside of the ul and doesnt print the li's either.... like:

    Apr.25.05<ul class="datelist">

    anyone see whats wrong?

    thanks alot....

  2. Kafkaesqui

    Posted 11 years ago #

    $mydate = the_date("M.d.y", "", "", FALSE);

    See the info on the echo parameter for the_date():


  3. lokjah
    Posted 11 years ago #

    excellent kafkaesqui

    I was reading that page actually all nite and forgot to put that piece into the script...

    thanks a ton!

  4. lokjah
    Posted 11 years ago #

    rats... thought it was sussed...

    for some reason my script above doesnt work like the_date
    as it should- (only showing the date on the first post when there are multiple posts on one day)...

    on days with more than one entry my script writes an empty
    <ul class="datelist">

    which throws off the validation of my site.....

    is there something that needs to be added in my script so that it behaves as the_date by default on multiple posts?

  5. lokjah
    Posted 11 years ago #

    still havent been able to figure this one out, help much appreciated :)

  6. Kafkaesqui

    Posted 11 years ago #

    Again I direct you to the Codex page, this time the description section:


    "When there are multiple posts published on the same date on a page, the tag will only display the date the first time it's called."

    So try this:

    $mydate = get_the_time("M.d.y");


  7. lokjah
    Posted 11 years ago #

    thanks kafka, i'm still a noob at php so it takes me a bit to get a hold of what to do,

    i know about the tag only the first time its called, thats what i was expecting my script above to do, but it wasnt doing that.

    this you posted works, it actually puts a date on every entry which is fine, I just wondered why the original the_date in my script wasnt working....

Topic Closed

This topic has been closed to new replies.

About this Topic