WordPress.org

Support

Support » How-To and Troubleshooting » php includes in pages

php includes in pages

Viewing 12 replies - 1 through 12 (of 12 total)
  • What do you mean by a “static page”? Are you referring to a WordPress “Page” (which aren’t static BTW) or a true static page like an .html document?

    <?php include(‘filename’); ?>

    or

    <?php require_once(‘filename’); ?>

    I mean the wordpress ‘page’.

    when i add <?php include(‘filename’); ?> , it just puts that there and not the file.

    Unless you run a plugin that allows for running PHP in posts and Pages – you can’t.
    Here is one of those plugins: http://wordpress.org/support/topic/52928?replies=6

    Ok you really need to link us to the page your tring to do this too…

    Also you can’t just copy what I have and paste it in the post section of the site and it work. You will need to edit the template and then change the file name to the includes that you need.

    example

    <?php
    include(‘test.php’);
    ?>

    Using an “include” in a template or using php in a Page – those are two different things. My impression was the OP asked for a Page, not a template.

    Yea I got that impression after I read the other post …

    As said, you can’t do PHP in posts. You’ll need a PHP plugin or even better, make a custom Page template.

    http://codex.wordpress.org/Pages#Page_Templates

    exactly , i was trying to add a php include into a ‘page’ and instead of the code running I got the text of the code.

    thanks moshu for your help.

    i was hoping it would be easier then creating a custom template with the code in it. But i guess the plugin might be easier so i will try that.

    Not hard. Just make a copy of your page.php and rename it to something else.

    Plus add some lines at the top 🙂

    You can also try CG-QuickPHP for something THAT simple (i.e., one ‘function’ used, and ‘static’ variables…). The format would be like:

    <quickphp include('filename'); />

    Note of course that it’s great if you know the absolute path to the file — but not if you want to use PHP variables to determine a file path, etc.

    Just thought I’d toss in another (fast) option.

    -d

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘php includes in pages’ is closed to new replies.