Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-02-2012, 09:44 PM   PM User | #1
The Noob Coder
New Coder

 
Join Date: Jul 2012
Posts: 72
Thanks: 1
Thanked 0 Times in 0 Posts
The Noob Coder is an unknown quantity at this point
Question Why doesn't Wordpress allow my PHP code?

I was using PHP to try and include a small snippet of HTML contained in an external file on my server. This is the line that I coded in:
PHP Code:
<?php include("path_to_file/file_name.html"); ?>
When I loaded the page, nothing was there. So I decided to open up the error console on Chrome. What I found was that my line of PHP was commented out:
Code:
<!--<?php include("path_to_file/file_name.html"); ?>-->
Since I and the CMS (Wordpress) are the only ones that control the code on my site, I figured it had to be WP that commented it out. Why did it do that? How can I stop it from commenting out my PHP?

I know for a fact that most of the content on WP is generated via PHP, if you look at the obscure backend WP files that are used to build the site so it doesn't make much sense to me.
The Noob Coder is offline   Reply With Quote
Old 10-02-2012, 10:00 PM   PM User | #2
Keleth
Senior Coder

 
Join Date: Jun 2008
Location: New Jersey
Posts: 2,354
Thanks: 45
Thanked 247 Times in 244 Posts
Keleth is on a distinguished road
Did you enter this into the WYSIWYG or into the file itself?
Keleth is offline   Reply With Quote
Old 10-02-2012, 10:03 PM   PM User | #3
The Noob Coder
New Coder

 
Join Date: Jul 2012
Posts: 72
Thanks: 1
Thanked 0 Times in 0 Posts
The Noob Coder is an unknown quantity at this point
Quote:
Originally Posted by Keleth View Post
Did you enter this into the WYSIWYG or into the file itself?
I am editing in the HTML view. I never use the WYSIWYG Visual editor.
The Noob Coder is offline   Reply With Quote
Old 10-05-2012, 08:24 PM   PM User | #4
The Noob Coder
New Coder

 
Join Date: Jul 2012
Posts: 72
Thanks: 1
Thanked 0 Times in 0 Posts
The Noob Coder is an unknown quantity at this point
Exclamation

Thread Bump
The Noob Coder is offline   Reply With Quote
Old 10-08-2012, 02:35 PM   PM User | #5
The Noob Coder
New Coder

 
Join Date: Jul 2012
Posts: 72
Thanks: 1
Thanked 0 Times in 0 Posts
The Noob Coder is an unknown quantity at this point
Thread Bump

Thread Bump
The Noob Coder is offline   Reply With Quote
Old 10-10-2012, 01:14 AM   PM User | #6
Wuteverx1972
New Coder

 
Join Date: Aug 2010
Posts: 53
Thanks: 6
Thanked 1 Time in 1 Post
Wuteverx1972 is an unknown quantity at this point
By default, wordpress will not allow php scripts in the html editor. You can manually input the php script by actually editing the page template or you can download a plugin for wordpress to allow php scripts to be executed using the html editor.

WP PHP Plugin: http://wordpress.org/extend/plugins/shortcode-exec-php/
Wuteverx1972 is offline   Reply With Quote
Old 10-12-2012, 11:15 PM   PM User | #7
The Noob Coder
New Coder

 
Join Date: Jul 2012
Posts: 72
Thanks: 1
Thanked 0 Times in 0 Posts
The Noob Coder is an unknown quantity at this point
Question

Quote:
Originally Posted by Wuteverx1972 View Post
By default, wordpress will not allow php scripts in the html editor. You can manually input the php script by actually editing the page template or you can download a plugin for wordpress to allow php scripts to be executed using the html editor.

WP PHP Plugin: http://wordpress.org/extend/plugins/shortcode-exec-php/
Thanks. I think this will work.

Last edited by The Noob Coder; 10-12-2012 at 11:44 PM..
The Noob Coder is offline   Reply With Quote
Reply

Bookmarks

Tags
commenting, php, wordpress

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:52 PM.


Advertisement
Log in to turn off these ads.