简体   繁体   中英

Inserting a PHP page into Wordpress

I know this is a fairly simple task but I think there's something I'm missing here. I want to put in a PHP page I have built from another site into my current Wordpress site, beneath the content section and above the footer. There is no coding within this section, just content. It only needs to be called upon and appear where I need it to on the page.

Some searching has lead me to believe it belongs in the page or single template before the footer. I've tried include tags and the like without any luck. Can anyone shed some light on this? Any help will be really appreciated.

Go to the footer.php from your Wordpress theme and add

<?php include once("/path/to/your/script.php"); ?>

after the last

<php get_sidebar(''); ?>

include.

It depends on your wordpress theme and layout. Basically you need to include this php file in the template for the page that you want it to appear on. Generally this is the index.php file for the post page and page.php for pages. You can check which template your pages are using by going into the dashboard and editing the page (the option is on the right hand side under 'template')

If you're unsure you may want to look here for more info: http://codex.wordpress.org/Template_Hierarchy

if your php file located on other website/server you can use file_get_contents to get its content and display it in your page.

Go to single.php and put this code between get_sidebar() and get_footer()

<?php 
    $mycontent = file_get_contents('http://example.com/your-php-file.php');
    echo $mycontent;
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM