WordPress.org

Ready to get started?Download WordPress

Forums

Display post date and time (16 posts)

  1. BlackDahlia
    Member
    Posted 9 years ago #

    For each title of my blog post, I want to have it display PHP. The PHP shows the time and date that the entry was posted. How can I go about doing that? I have the PHP coding, I just need to know how I can make WordPress publish it.

  2. NuclearMoose
    Member
    Posted 9 years ago #

  3. Kafkaesqui

    Posted 9 years ago #

    You're going to have to give a little more information about your request. For example: You want it to display PHP. PHP? Do you mean PHP code of your own devising, or WordPress "template tags"?

    Post time and date are built-in template tags or functions you an use. Check out the documentation on their use:

    http://codex.wordpress.org/Template_Tags/the_date
    http://codex.wordpress.org/Template_Tags/the_time

  4. BlackDahlia
    Member
    Posted 9 years ago #

    This is the string of PHP I want it to display in the header of my page:

    <?php echo date("F j, Y | g:i a"); ?>

  5. Kafkaesqui

    Posted 9 years ago #

    Look over the links provided above for the_date() and the_time(), which are WordPress functions specific to date/time on posts.

  6. NuclearMoose
    Member
    Posted 9 years ago #

    Well, you can't just use that code because it won't reflect the date of the post as it is stored in the database.

  7. BlackDahlia
    Member
    Posted 9 years ago #

    OK. What I meant to say by the way was that I want the time and date displayed for each of the titles, I don't think I'm gonna have any specific titles for each post.

  8. Kafkaesqui

    Posted 9 years ago #

    What are the titles linked to then?

  9. BlackDahlia
    Member
    Posted 9 years ago #

    This is what I want to do:

    I had my header defined in the CSS. I want the title, which will be the date and time, that I put in WordPress to publish to come out so that the CSS recognizes it and makes it look like the rest of the headers on my site. The setup I want for it is:

    date | time

    post

  10. Kafkaesqui

    Posted 9 years ago #

    And again, what does title, date | time, or whatever relate to? If it's just the current date and/or time, then your code should work fine, but if it's for a post, then you need to use the template tags mentioned above, since they'll display it for the post.

  11. BlackDahlia
    Member
    Posted 9 years ago #

    So I can put normal PHP coding as my title and everything should work out, right?

  12. Kafkaesqui

    Posted 9 years ago #

    It appears we're crossing wire here:

    Your "normal PHP coding" will work, but it won't reflect anything related to the post, i.e. when it was actually published. Hence the reason for the template tags, which are in a sense *normal* PHP, but functions specific to WordPress.

  13. BlackDahlia
    Member
    Posted 9 years ago #

    OK what I want to do is show the time and date that the entry was posted. How can I do that?

  14. NuclearMoose
    Member
    Posted 9 years ago #

    Visit the direct links that Kaf provided for you above and that will explain what you need to do.

  15. BlackDahlia
    Member
    Posted 9 years ago #

    Alrighty.

  16. Amanda Rush
    Member
    Posted 9 years ago #

    Hello:

    I am a new wordpress user, and for now am using the default WordPress theme, because it works with the Hebrew date blugin I'm using. However, the time and author are not being shown on my posts. I looked at the main template for the theme, and it looks like the template tags are there, within <small> </small> tags. What do I do next in order to get that information displayed, so that the date displays, and then "posted by ... at ..."? Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.