Title: Add php code in pages
Last modified: August 22, 2016

---

# Add php code in pages

 *  [daimpa](https://wordpress.org/support/users/daimpa/)
 * (@daimpa)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/add-php-code-in-pages/)
 * Hello,
 * I need to execute php code in my wordpress pages to extract/insert data from 
   a mysql database.
 * I’ve to create two php pages.
 * In the first one I’ve to extract and print a table from my database.
    In the 
   second one I’ve to create a form to insert data into the database.
 * Unfortunatly, I just found out that by default I can’t add PHP code to a wordpress
   page. What can I do?
 * I’ve looked for plugins to execute PHP code in pages, but everyone seems to be
   outdated/not compatible with 4.0.1.

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

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/add-php-code-in-pages/#post-5566163)
 * The best, and most compatible, way to do it is to [create your own shortcodes](http://codex.wordpress.org/Shortcode_API).
   This will let you set up the extra content where ever it needs to go in the page
   content.
 *  Thread Starter [daimpa](https://wordpress.org/support/users/daimpa/)
 * (@daimpa)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/add-php-code-in-pages/#post-5566293)
 * What if I assign a page template to the page, I remove the php code to fetch 
   page-content from wp-database and I execute my personal php code?
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/add-php-code-in-pages/#post-5566315)
 * Sure, that’s very easy. Just remove the call to the `the_content()` function 
   and add in your own code.

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

The topic ‘Add php code in pages’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/add-php-code-in-pages/#post-5566315)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
