Title: How to get Post Snippet Variable in php code
Last modified: August 31, 2016

---

# How to get Post Snippet Variable in php code

 *  Resolved [ljkeashly](https://wordpress.org/support/users/ljkeashly/)
 * (@ljkeashly)
 * [10 years ago](https://wordpress.org/support/topic/how-to-get-post-snippet-variable-in-php-code/)
 * Hi,
 * I have a page with this post snippet on it:
    `[form1 page="abc"]`
 * Because the form is so long and complex I have it in a php file, so in the Post
   Snippet I have:
    `include('content/form1.php');`
 * Now in form1.php I want to put the value of the ‘page’ variable in a hidden form
   field. Using {page} in the php file doesn’t work. How do I access the variable
   in the php code? Is it possible?
 * Thank you.
 * [https://wordpress.org/plugins/post-snippets/](https://wordpress.org/plugins/post-snippets/)

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

 *  [Johan Steen](https://wordpress.org/support/users/artstorm/)
 * (@artstorm)
 * [10 years ago](https://wordpress.org/support/topic/how-to-get-post-snippet-variable-in-php-code/#post-7389586)
 * How far do you get it working? You get the include file loaded, but not the variable
   injected?
 *  Thread Starter [ljkeashly](https://wordpress.org/support/users/ljkeashly/)
 * (@ljkeashly)
 * [10 years ago](https://wordpress.org/support/topic/how-to-get-post-snippet-variable-in-php-code/#post-7389591)
 * Hi,
 * Yes, when I used {page} in the php include file it includes {page} rather than
   the value of page. So what I did was make a function that has some parameters
   and wrapped the included code in the function. Doing it this way worked. So, 
   I have:
    `include('content/form1.php'); function form1 ({page});`
 * Now in the included php file I can put form1 function’s parameter anywhere I 
   need and it works.
 * Thank you for your response.

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

The topic ‘How to get Post Snippet Variable in php code’ is closed to new replies.

 * ![](https://ps.w.org/post-snippets/assets/icon-128x128.gif?rev=2545587)
 * [Post Snippets - Custom WordPress Code Snippets Customizer](https://wordpress.org/plugins/post-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/post-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-snippets/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [ljkeashly](https://wordpress.org/support/users/ljkeashly/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/how-to-get-post-snippet-variable-in-php-code/#post-7389591)
 * Status: resolved