fed Posted October 29, 2015 Share Posted October 29, 2015 Hi guys, I have a wordpress website and I'd like to use the header in a custom HTML page in which I complete the body and footer with HTML5, CSS and Javascript. What's my best option: do I create a PHP file which includes the HTML (option 1) or do I create a HTML file which includes the reference to header.php (option 2)? The purpose is that I can point directly to this page (e.g. mypage.html) from both a wp and non-wp website. As such, how would the code look like so that it "recognizes/finds" header.php and also links to the corresponding CSS and JS files which is required to complete the body and footer? Thanks for helping me out. Fed Quote Link to comment https://forums.phpfreaks.com/topic/298905-include-php-header-in-html-or-the-other-way-around/ Share on other sites More sharing options...
scootstah Posted October 29, 2015 Share Posted October 29, 2015 or do I create a HTML file which includes the reference to header.php (option 2)? You can't use PHP in HTML files. The simple option is this: <?php include 'header.php'; include 'page.php'; include 'footer.php';The middle include would probably dynamically include the page you requested, but you get the idea. Quote Link to comment https://forums.phpfreaks.com/topic/298905-include-php-header-in-html-or-the-other-way-around/#findComment-1524698 Share on other sites More sharing options...
QuickOldCar Posted October 29, 2015 Share Posted October 29, 2015 You can create a custom page template and use your themes header, footer, sidebar and replace just the content area with what you want. <?php /* Template Name: CustomPage */ ?> <?php get_header(); ?> <style> <!-- div.newcontent { width: 80%; background:#000000; color:#DF0101; text-decoration: none; text-align:center; margin-top:0px; margin-bottom:0px; margin-right: auto; margin-left: auto; padding:0px; } --> </style> <?php echo "<div class='newcontent'>"; echo "Any code gets added this area"; echo "</div>"; ?> <?php get_footer(); ?> Save that as custompage.php inside your current themes directory Go to your dashboard Create a new page and name it what you desire At the bottom right under "Page Attributes" select the "CustomPage" under "Template" Publish your page Quote Link to comment https://forums.phpfreaks.com/topic/298905-include-php-header-in-html-or-the-other-way-around/#findComment-1524716 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.