I have used PHP on a page to include HTML files on a page such as:
<?php require(".html"); ?>
This works well for including a single file that gets updated frequently.
I am hoping to find a way to use PHP code in a single Wordpress Page that would included one of several HTML files depending on the URL. The idea would be to be able to create a URL to a Wordpress page that would have the name of the HTML file as a variable that the PHP script would use to identify the desired HTML file to include.
I have used PHP on a page to include HTML files on a page such as:
<?php require("http://www.mysite.edu/_sports/static/season_box.html"); ?>
This works well for including a single file that gets updated frequently.
I am hoping to find a way to use PHP code in a single Wordpress Page that would included one of several HTML files depending on the URL. The idea would be to be able to create a URL to a Wordpress page that would have the name of the HTML file as a variable that the PHP script would use to identify the desired HTML file to include.
Share Improve this question edited Sep 23, 2012 at 5:30 Ron Smith asked Sep 23, 2012 at 5:13 Ron SmithRon Smith 111 bronze badge 1- 2 Hi Ron, welcome to WPSE! Some explanation about your question title: The URL value is named "query part" of a "query string". I'm sure google will give you enough results, so you can get back and bring this question on topic and make it easier to understand. Thanks. – kaiser Commented Sep 23, 2012 at 8:37
1 Answer
Reset to default 0Assuming you already set permalinks for your Wordpress site, add this to your page.php
:
<?php
include("http://www.mysite.edu/_sports/static/".$post->post_name.".html);
?>
$post->post_name
would be the slug of your page.
If you're in a page with the slug volleyball-box-score
, with the code above, you would get include("http://www.mysite.edu/_sports/static/volleyball-box-score.html);
. If you're in a page with the slug other-page
, you would get include("http://www.mysite.edu/_sports/static/other-page.html);
. Etc.