1

My php code is called from the html code in a wordpress page. However It is being commented out by the browser. The code:

<?php if (function_exists (gCF)) gCF(); ?>

inside a div is being read as following (when I see in firebug or chrome)

<!--?php if (function_exists (gCF)) gCF(); ?-->

I searched the net and found following similar questions, but sadly there is no apt solution, and nor has anyone mentioned why this is happening. Is it because of doctype???

Question 1 Question 2 Question 3 Question 4

Thanks in advance.

Community
  • 1
  • 1
user1517108
  • 2,395
  • 6
  • 32
  • 43

3 Answers3

6

It sounds to me like the code is inside a file that does not have a .php extension and therefore the code is being evaluated as HTML.

If you want to use php in wordpress, make sure it's in a template file (either an existing one or one that you've made).

What have you tried
  • 11,018
  • 4
  • 31
  • 45
1

By default, Wordpress does not support the use of PHP code directly in a post. A simple Google search brought up some possible plugins that could allow you to do this.

NateWr
  • 235
  • 3
  • 12
0

It's possible that the file is not being parsed by PHP. Make sure the file extension is PHP or your server is setup to parse that filetype using PHP.