I have a short-code that uses PHP to echo a time stamp ala: 1595140137 When I use that short-code as the default post title in new post, the post title changes with each page refresh, and in the browser title area, it just renders the short code characters. I have even double bracketed the short-code. Any ideas? Thanks.

  • Well it changes because the time changes ;-) Is what you want for it to store the time when the post is created, and always show the time the post was created? – mozboz Jul 19 at 11:04
  • Yes. I want to name the post the current timestamp, and it stays that number forever. – mobilestimulus Jul 19 at 11:59
  • That's a bit more complicated, so you might have to do something like in your shortcode ask Wordpress for the time the post was created instead of the time now. Or if that value isn't right for you, then store the time in e.g. a post meta field the first time the short code runs and use that value in future. – mozboz Jul 19 at 12:04
  • I am using a "front end user post" plugin to display a form with a hidden post-title field, and the default value should be the [timestamp] output. – mobilestimulus Jul 19 at 12:05
  • 1
    But the timestamp is going to be updated with the time, so the hidden field will always be updated. When it saves to the DB it should stay saved. When you view the created post are you still viewing it as a form? If that's the case then you should run a check on whether or not that value already exists and if it does, don't load the hidden field. So basically make the hidden field conditional on whether or not the get_the_title() is empty. – Tony Djukic Jul 19 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.