WordPress.org

Ready to get started?Download WordPress

Forums

Download Monitor
[resolved] content and date in templates (11 posts)

  1. Li-An
    Member
    Posted 1 year ago #

    Hello,
    I found how to show content of the new created custom post in templates <?php the_content(); ?> seems to work. But I cannot find how to show the date. I tried <?php $dlm_download->post->post_date; ?> but nothing is showing.

    (I post here because I suppose users can be interested).

    http://wordpress.org/extend/plugins/download-monitor/

  2. mikejolley
    Member
    Plugin Author

    Posted 1 year ago #

    You missed the 'echo'.

    <?php echo $dlm_download->post->post_date; ?>

  3. Li-An
    Member
    Posted 1 year ago #

    Thanks. Do I need to use post_content instead of the_content ?

    And how format the date ?

  4. mikejolley
    Member
    Plugin Author

    Posted 1 year ago #

    $dlm_download->post->post_content;

    post_date returns a date string - you can use PHP functions such as strtotime() and date() to manipulate the format.

  5. Li-An
    Member
    Posted 1 year ago #

    Thanks. I will take a look at that.

  6. Li-An
    Member
    Posted 1 year ago #

    Hello,

    content_date gives the date of the custom post not of the files upload. How to get this ?

  7. mikejolley
    Member
    Plugin Author

    Posted 1 year ago #

    The file upload date is not stored because you can paste in file urls and it has no way of knowing the date.

    If you want the date the download was last modified use ->post_modified

    If you want the date the 'version' was created, there is no function. But it can be retried though get_post on the version ID.

    http://codex.wordpress.org/Function_Reference/get_post

  8. Li-An
    Member
    Posted 1 year ago #

    OK, so to be sure I understood: there is no direct function to get this date http://tof.canardpc.com/show/432e1f6d-4e32-41ae-82eb-c78fd2242b79.html ?

    I suppose it will be OK with post_modified...

  9. domdeez
    Member
    Posted 5 months ago #

    I added <?php echo $dlm_download->post->post_date; ?> to a template file and it pulled the date.

    How can i get it formatted properly, with no time.

    2014-03-18 17:19:39 to March 18, 2014

  10. domdeez
    Member
    Posted 5 months ago #

    This will get the post date to display in a reasonable format.

    <?php echo date('F j, Y', strtotime($dlm_download->post->post_date));?>

    Turns this: 2014-03-18 17:19:39

    Into this: March 18, 2014

  11. Li-An
    Member
    Posted 5 months ago #

    Thank you.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.