ThemeShaper Forums » Thematic

[closed]

correct use of thematic_postmeta_entrydate()

(4 posts)
  • Started 4 years ago by JC
  • Latest reply from darrenc
  • This topic is resolved
  1. JC
    Member

    I putting this again here because last thread was already closed, sorry

    Hi !
    Thank you Ian and Chris , I'am enjoying using Thematic, and it makes me use my brains ;-)

    So now that thematic_postmeta_entrydate() has been implemented I'am trying to style by applying a filter but with no success so far (sorry I'm not very good at coding)
    This is what I tryied so far :

    // Add a custom post meta entry date
    
    function my_postheader_date() {
    
    global $post; ?>
    
    <span class="entry-date">
    <span class="month"><?php the_time('M') ?></span>
    <span class="day"><?php the_time('d') ?></span>
    </span>
    
    <?php add_filter('thematic_postmeta_entrydate','my_postheader_date');
    
    } ?>

    but no luck :(
    Someone please could take a look and direct me to the solution ?

    Thanks a lot

    Posted 4 years ago #
  2. JC
    Member

    Ok, to self: remember to better read the docs ....

    This achieved what I was looking for

    function my_postmeta_entrydate() {
    
        $entrydate .= '<span class="entry-date"><abbr class="published" title="';
        $entrydate .= get_the_time(thematic_time_title()) . '">';
        $entrydate .= '<span class="month">' . get_the_time('M') . '</span>';
        $entrydate .= '<span class="day">' . get_the_time('d') . '</span>';
        $entrydate .= '<span class="year">' . get_the_time('Y') . '</span>';
        $entrydate .= '</abbr></span>';
    
        return apply_filters('thematic_post_meta_entrydate', $entrydate);
    
    } // end my_postmeta_entrydate()
    
    add_filter('thematic_postheader_postmeta','my_postmeta_entrydate');

    Then I could format the date the way I wanted with css to achieve something like this:

    FEB
    15
    2010

    Hope this helps somebody, and spares hours of research

    Thanks

    Posted 4 years ago #
  3. Pictrix
    Member

    I was trying to do exactly the same without success: When apply the filter described above to my functions.php,only the date is displayed and both the author and the edit links disappear.

    I know about Ian's working filter for the postheader, but I am trying to understand why this approach doesn't work. Any insight will be appreciated, since I'm new to PHP.

    Posted 4 years ago #
  4. darrenc
    Member

    pictrix i understand now why this approach doesn't work as expected. thanks to helgatheviking, i worked through it here hopefully showing it more clarity/detail.

    by using the code

    add_filter('thematic_postheader_postmeta','my_postmeta_entrydate');

    JC is replacing the entire thematic_postheader_postmeta... which includes the opening div, authorlink, seperators, entrydate, editlink, and closing div.

    if you follow the entrydate function to its origin you can find that the filter you need to use to replace JUST the date is actually "thematic_post_meta_entrydate"

    given that, here is the code to specifically target just the date

    function my_postmeta_entrydate($entrydate) {
        $entrydate = '<span class="entry-date"><abbr class="published" title="';
        $entrydate .= get_the_time(thematic_time_title()) . '">';
        $entrydate .= '<span class="month">' . get_the_time('M') . '</span>';
        $entrydate .= '<span class="day">' . get_the_time('d') . '</span>';
        $entrydate .= '<span class="year">' . get_the_time('Y') . '</span>';
        $entrydate .= '</abbr></span>';
        return $entrydate;
    } // end my_postmeta_entrydate()
    add_filter('thematic_post_meta_entrydate','my_postmeta_entrydate');
    
    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.