• Resolved joneslee85

    (@joneslee85)


    Hello there,
    I am going to design a short-news style for the post content.

    for example:

    <November 10th 2009> – <paragraph1>
    <paragaph2>

    My question is how to take advantage of filter or action to add the timestamp into the first paragraph of the_content(). Please help. Many thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter joneslee85

    (@joneslee85)

    Example:

    November 29th, 2009 – Inspire Generations (IG) launches website and is now accepting volunteers starting 1st Jan 2010. IG is offering a very special deal for its grand opening. We are offering 50% off applications fees if you apply before 1st Feb 2010.”

    Blah blah blah blah

    Blhahah

    ————-

    November 27th, 2009 – Inspire Generations (IG) launches website and is now accepting volunteers starting 1st Jan 2010. IG is offering a very special deal for its grand opening. We are offering 50% off applications fees if you apply before 1st Feb 2010.”

    Blah blah blah blah

    Blhahah

    This in your theme’s functions.php should work:

    function prepend_date_to_content($content) {
    global $post;
    $content = mysql2date("F j, Y", $post->post_date) . ' - ' . $content;
    return $content;
    }
    add_filter( 'the_content', 'prepend_date_to_content',9 ); //using priority 9 to force filter to act before wpautop

    try something like (in the loop):

    <div class="entry">
    <span><?php the_time(' F j Y'); ?> - </span>
    <?php the_content(__('(more...)')); ?>
    </div>

    and the style:

    .entry {
    font-size: 115%;
    line-height:1.5;
      }
    .entry span {
    float:left;
    margin:0;
    padding:0px 5px 0 0;
      }
    .entry p {
    margin:3px 0 12px 0;
      }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to add timestamp to the_content()’ is closed to new replies.