Help with titles with include_once

Hi. Thanks for reading.

Hope someone can help me. My programming man is unavailable and I would love to get this done without him - today.

I am developing a site which uses include_once to include a header, footer, navigation etc into content pages. The header file contains most of the of each page such as the .

On each content page we have $title variable which we use to display a different title on each page. I hope I am being clear.

This works fine of course, my problem is as follows:

I have some blog software (Wordpress) in one directory of the site, and am having problems getting the titles of these pages into my header. The index.php of Wordpress (if anyone is familiar with it) has the include_once for the header, and $title to give it a title.

The title of the Wordpress articles are stored in <?php the_title(); ?>. How can I put that into the $title variable so it is passed onto the header include?

I have tried

$title = ‘<?php the_title(); ?>’
&
&title = ‘the_title()’

which I guessed was wishful thinking.

Sorry this is extremely long winded and the tech jargon probably incorrect. I’ve experimented a bit - but something tells me it is more complicated than my ability. Do I have to write a new function or something?

Any help greatly appreciated.

Andy.

In plain English:

Can I do something like this?


$title = '<?php post_title() ?>'

???

Or do I need to somehow include that in the header.php first, maybe by calling a function?

Sorry this makes no sense. Basically I don;t have a clue what I’m doing.

Andy.

$title = the_title();

Aha…

Great. That sends the title of the post correctly, but for some reason in the final html document the browser receives, it comes at the very beginning - before the DOCTYPE Declaration, and not in the .

I have used:


<title><?php echo $title ?></title>
	

In fact. Where ever I put the code

<?php echo $title ?>

in the header.php file, it always appears on the first line of the html.

Why is this?

Andy.

Sponsor our Newsletter | Privacy Policy | Terms of Service