Title: Using PHP in pages
Last modified: October 30, 2017

---

# Using PHP in pages

 *  Resolved [jperry89](https://wordpress.org/support/users/jperry89/)
 * (@jperry89)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/using-php-in-pages-2/)
 * I need to know how to get individual snippets of PHP to work in a Post, rather
   than just using it for the entire website as a whole.
 * What I need to do is create a some way to enter a number into a box and press
   a button that shows you some results from a database, and the code does work 
   perfectly, just not on WordPress because WordPress doesn’t let you use PHP in
   pages. I tried a few plugins to for PHP shortcodes but it never works correctly.

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

 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/using-php-in-pages-2/#post-9634451)
 * Review the source code of these two plugins to get some idea:
 * [https://wordpress.org/plugins/insert-php/](https://wordpress.org/plugins/insert-php/)
   
   [https://wordpress.org/plugins/allow-php-in-posts-and-pages/](https://wordpress.org/plugins/allow-php-in-posts-and-pages/)
 * Please note, just in general, one should avoid using plugins and themes that 
   are not actively being maintained (such as the above plugins) as they do have
   an increased security vulnerability.
 * However, reviewing their source code, you might be able to get some idea to create
   your own solution.
    -  This reply was modified 8 years, 7 months ago by [t-p](https://wordpress.org/support/users/t-p/).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/using-php-in-pages-2/#post-9634509)
 * IMO, PHP in page content plugins are a security risk. Many have used these without
   issues though. You should be able to achieve what you want without the risk by
   using either [shortcodes](https://developer.wordpress.org/plugins/shortcodes/)
   and/or custom [page templates](https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-page-templates-for-global-use).
   The only thing these would not allow is individuals creating PHP on the fly as
   they write page content. As long as the PHP is pre-determined, these will work
   for you.
 *  Thread Starter [jperry89](https://wordpress.org/support/users/jperry89/)
 * (@jperry89)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/using-php-in-pages-2/#post-9636657)
 * Yeah did think that. I might be able to bypass the problem altogether by hosting
   the tool on the server but separate from the wordpress site then linking to it
   via a popup, rather than trying to force it to work on the site itself. I’d rather
   people have to click a button and maybe authorize popups than risk a security
   issue.
 *  Thread Starter [jperry89](https://wordpress.org/support/users/jperry89/)
 * (@jperry89)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/using-php-in-pages-2/#post-9640139)
 * I bypassed the problem by linking to the tool via a popup rather than trying 
   to put it in the page itself. Sorry that always happens to me where you ask a
   question and then immediately solve it yourself.
 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/using-php-in-pages-2/#post-9641426)
 * Glad you got it sorted 🙂

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

The topic ‘Using PHP in pages’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [t-p](https://wordpress.org/support/users/t-p/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/using-php-in-pages-2/#post-9641426)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
