ThemeShaper Forums » Thematic

[closed]

Post time: <span>day</span><span>month</span> etc

(7 posts)
  • Started 4 years ago by markarse
  • Latest reply from keco86
  • This topic is resolved
  1. markarse
    Member

    Okay it's easy enough to specify your preferred format for the post date:

    function my_time_display($time_display) {
      return 'm. F Y';
    }
    add_filter('thematic_time_display','my_time_display');

    BUT

    What if I need each element of the time in it's own <span> element? How is it done?
    ie.

    <span>16.</span><span>February</span><span>2010</span>

    Reason being I'd like to stack each span and style them individually.

    Posted 4 years ago #
  2. Hi,

    just escape the right characters :)

    function my_time_display($time_display) {
      return '<\sp\a\n>m.</\sp\a\n><\sp\a\n>F</\sp\a\n><\sp\a\n>Y</\sp\a\n>';
    }
    add_filter('thematic_time_display','my_time_display');

    Chris

    Posted 4 years ago #
  3. .. do me a favor and drop a link for the result :)

    Chris

    Posted 4 years ago #
  4. markarse
    Member

    Great!

    Now adding id or class attributes would be very handy. Through trial and error I can see that this works:

    <\sp\a\n \i\d="f\o\o">m.</\sp\a\n>

    What's your method for properly escaping for the date function?
    Is it just referring back to http://au2.php.net/manual/en/function.date.php ?

    Posted 4 years ago #
  5. markarse
    Member

    For anybody wanting to customise their post dates so that the day, month and year are within their own spans, see the code below. I broke the date string down into its tokens using the strtok() function (using a hyphen as the separator). Note that the time display function has hyphens in it. This goes in your functions.php file.

    function my_time_display($time_display) {
      return 'M-d-Y';
    }
    add_filter('thematic_time_display','my_time_display'); 
    
    function my_postmeta_entrydate() {
    
         $entrydate = '<span class="meta-prep meta-prep-entry-date">' . __('Published: ', 'thematic') . '</span>';
         $entrydate .= '<span class="entry-date"><abbr class="published" title="';
         $entrydate .= get_the_time(thematic_time_title()) . '">';
    
         $date = get_the_time(thematic_time_display());
         $day = '<span id="month">' . strtok($date, '-') . ' </span>';
         $month = '<span id="day">' . strtok('-') . ' </span>';
         $year = '<span id="year">' . strtok('-') . ' </span>';
    
         $entrydate .= $day . $month . $year;
         $entrydate .= '</abbr></span>';
         return $entrydate;
    }
    add_filter('thematic_post_meta_entrydate', 'my_postmeta_entrydate');
    Posted 4 years ago #
  6. Trying to add a blank space between thematic_time_display proved quite tricky.

    I had to escape this in the end and style the "." to my background colour.

    return 'j<\sp\a\n/\i\d="b\l\a\n\k">.</\sp\a\n>F<\sp\a\n>,</\sp\a\n><\sp\a\n/\i\d="b\l\a\n\k">.</\sp\a\n>';

    Not ideal. There must be an easier way to add a blank space into the string.

    Posted 3 years ago #
  7. This is exactly what I needed thank you for posting it.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.