Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder The Noob Coder's Avatar
    Join Date
    Jul 2012
    Location
    The City that Never Sleeps
    Posts
    99
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Did you enter this into the WYSIWYG or into the file itself?

  • #3
    New Coder The Noob Coder's Avatar
    Join Date
    Jul 2012
    Location
    The City that Never Sleeps
    Posts
    99
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New Coder The Noob Coder's Avatar
    Join Date
    Jul 2012
    Location
    The City that Never Sleeps
    Posts
    99
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation

    Thread Bump

  • #5
    New Coder The Noob Coder's Avatar
    Join Date
    Jul 2012
    Location
    The City that Never Sleeps
    Posts
    99
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thread Bump

    Thread Bump

  • #6
    New Coder
    Join Date
    Aug 2010
    Posts
    53
    Thanks
    6
    Thanked 1 Time in 1 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/

  • #7
    New Coder The Noob Coder's Avatar
    Join Date
    Jul 2012
    Location
    The City that Never Sleeps
    Posts
    99
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •