Title: Need direction on function logic
Last modified: December 13, 2016

---

# Need direction on function logic

 *  [jwest100](https://wordpress.org/support/users/jwest100/)
 * (@jwest100)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/need-direction-on-function-logic/)
 * 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 9 years, 5 months ago by [jwest100](https://wordpress.org/support/users/jwest100/).
    -  This topic was modified 9 years, 5 months ago by [jwest100](https://wordpress.org/support/users/jwest100/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/need-direction-on-function-logic/#post-8548604)
 * 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](https://wordpress.org/support/users/jwest100/)
 * (@jwest100)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/need-direction-on-function-logic/#post-8548661)
 * 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](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/need-direction-on-function-logic/#post-8549836)
 * That’s right. [Function Reference/update post meta](https://codex.wordpress.org/Function_Reference/update_post_meta)
   
   Though the [Developer Reference](https://developer.wordpress.org/reference/functions/update_post_meta/)
   is slowly replacing the Codex in part. Then to get the data there’s [get_post_meta()](https://developer.wordpress.org/reference/functions/get_post_meta/).
 *  Thread Starter [jwest100](https://wordpress.org/support/users/jwest100/)
 * (@jwest100)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/need-direction-on-function-logic/#post-8549907)
 * 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.

## Tags

 * [css](https://wordpress.org/support/topic-tag/css/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [ipn](https://wordpress.org/support/topic-tag/ipn/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 4 replies
 * 2 participants
 * Last reply from: [jwest100](https://wordpress.org/support/users/jwest100/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/need-direction-on-function-logic/#post-8549907)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
