sf_tristanb
sf_tristanb

Reputation: 8855

Header how to modify title of the page "on the fly"

My header is called as you can imagine, on each pages.

it means that on each pages i've the same title (bad for SEO)

Is there a workaround to set pages title outside the header.php ?

Thanks

Upvotes: 3

Views: 14629

Answers (3)

ramuhuyu
ramuhuyu

Reputation: 31

include ('includes/header.php');
titleAndMeta('yourTitle');

This goes in your page and this goes in your header.php

function titleAndMeta($title)
 echo '<title>$title</title>';

Upvotes: -1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798516

Set a variable for the title before including the header, then output the variable within the header.

Upvotes: 3

nc3b
nc3b

Reputation: 16230

Make a variable $page_title. Set it before including the header and in the header have something like:

echo("<title>$page_title</title>");

Upvotes: 15

Related Questions