Home  >  Q&A  >  body text

How to make rand() function static in WordPress

I use wp_schedule_single_event() for scheduled publishing, and the value of post_content uses [shortcode]. I'm using rand() to generate random numbers and want to put them into each post.

The problem is, I want this random number to become permanent/static. So, every time you refresh the article, this number won't change.

P粉099000044P粉099000044427 days ago538

reply all(1)I'll reply

  • P粉402806175

    P粉4028061752023-09-12 09:53:30

    You must return the first rand() value stored in your post's post_meta, when you call your shortcode, check if the value exists, if not generate a value, if it exists use the value stored in Value

    in your post_meta

    reply
    0
  • Cancelreply