WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Embedding PHP Code

[Resolved] Embedding PHP Code

  • Hi:

    I have some PHP script that I’m trying to include on one of my pages. I’ve downloaded and installed several plugins that parse the php like exec-php, and runphp, but they don’t parse it correctly. If I put the PHP code in a blank page and run it directly (not having anything to do with WP), then it works fine.

    I was wondering if anyone has any other ideas I can try.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Just to clarify, when you say “one of my pages” are you referring to Pages ?

    Generally speaking, you can create a Pages#Page_Templates and include your php within that. Then go to Write –> Page and create the page using your custom template.

    The template can either just be the script, or it can have some dynamic content you add via the write panel plus your php code, all depending on if you include the loop in the template.

    If after reading over those links, you have more questions, by all means, check back.

    Hi,

    Thanks for the reply. Yes I was referring to Pages.

    I never thought of putting the code in the Pages.php file, and I actually tested it and it works fine that way. Here is my only problem, I only want that code to show in a particular Page. I notice each Page has an ID assigned to it. Is there a way in my page.php file to say something like (if page id = 1) { display code here }?

    If I can do do that, what is the exact code to use for that? Thanks for the help. =)

    take a look at the Pages Templates link again. You can create as many custom page templates as you desire. Then when you write page, you choose the particular template your code is on, instead of default.

    I’m working on my personal site and just about every “Page” is a different template.

    Okay I get it now. That is really helpful. I kept trying to find where to change the template, and finally read you actually need to upload one first. Good stuff.

    Thanks for your patience!

    Cheers.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Embedding PHP Code’ is closed to new replies.