CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   Why doesn't Wordpress allow my PHP code? (http://www.codingforums.com/showthread.php?t=274976)

The Noob Coder 10-02-2012 09:44 PM

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.

Keleth 10-02-2012 10:00 PM

Did you enter this into the WYSIWYG or into the file itself?

The Noob Coder 10-02-2012 10:03 PM

Quote:

Originally Posted by Keleth (Post 1275710)
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 10-05-2012 08:24 PM

Thread Bump

The Noob Coder 10-08-2012 02:35 PM

Thread Bump
 
Thread Bump

Wuteverx1972 10-10-2012 01:14 AM

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/

The Noob Coder 10-12-2012 11:15 PM

Quote:

Originally Posted by Wuteverx1972 (Post 1278172)
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.


All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.