Question

I've started creating a custom html page for the first time and i've hit a bump. The code in the header will be the same in all my pages , so i want to put it in an external file (header.php) and just put 1 line of code in all my pages to link to it but it doesn't seem to be working .

  • Note - I want to include just basic html code ( not a function ) - i'm thinking that's why its not working but not sure.

HTML file :

<body>

<?php include('header.php') ?>     // didn't work
<?php get_header(); ?>      // didn't work

<div class="content"> </div>

</body>

PHP File :

<h1>TITLE</h1>

When i put the code directly on the page - it shows "TITLE"

When i try include or get_header , i get a blank page . I checked the codex and online posts but i've not been able to fix it .

Any help would be appreciated - Thanks

Était-ce utile?

La solution

Try in your header.php:

<?php
echo "<h1>TITLE</h1>";
?>

Then where you want to insert the header:

<?php include '/header.php' ?>

The / character makes the path to header.php relative to your root.

Autres conseils

<?php include("dyn_layout/cbside_php.php"); ?>

This works for me... just don't forget to rename your files to .php extension... including the file where the insertion is made.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top