• I need a function that finds a specific post_id and declares a php variable in that post.

    It would print the declaration in the code.

    Any ideas?

    Thanks!

    • This topic was modified 8 years, 3 months ago by jwest100.
    • This topic was modified 8 years, 3 months ago by jwest100.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    If you start out knowing the post ID, you could store a value in post meta with update_post_meta(). Then when the post is output in the loop use get_post_meta() to determine that value and adjust output accordingly.

    I saw part of your original post in my feed reader. The above code would not affect what a user sees in their browser if they are the one who effected a change of state by purchasing something. In that case you still need to do the above server side, but additionally client side you need to update the page they are viewing. This is easiest done by reloading the page. Depending on how the payment is managed, this might happen automatically.

    Thread Starter jwest100

    (@jwest100)

    Excellent! Thank you soooooo much! That will work I’m sure ??

    Where can I find info on storing a value in post_meta? The codex?

    Moderator bcworkz

    (@bcworkz)

    That’s right. Function Reference/update post meta
    Though the Developer Reference is slowly replacing the Codex in part.
    Then to get the data there’s get_post_meta().

    Thread Starter jwest100

    (@jwest100)

    Thanks again! It worked perfectly ?? I just needed a push in the right direction.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Need direction on function logic’ is closed to new replies.