user3886174
user3886174

Reputation:

How can I give a title for each of my pages?

I would like to give a title to each of my pages, but all my pages are linked to my index.php:

<!DOCTYPE html>
<html lang="en-us">
    <head>
        <meta charset="UTF-8">
        <title>Test</title>
        <link href="css/style.css" rel="stylesheet" type="text/css">
        <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    </head>
    <body>
        <?php include("top_bar.php");?>
        <?php include("header.php");?>
        <?php include("container.php");?>
        <?php include("footer.php");?>
    </body>
</html>

Here is how my site is: http://prntscr.com/47nn7h

All my pages have the title I put for index.php, but how to add a title to a specific page (example, when I go to the page members.php)?

members.php:

<?php include "index.php";?>

Thanks.

Upvotes: 0

Views: 295

Answers (2)

user1864610
user1864610

Reputation:

Replace the existing <title> tag with this.

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

in your <head> block.

Make sure that $pagetitle actually contains the desired title before you emit the tag. It's not clear from your question where these titles are coming from - you'll probably need some PHP right at the top of the page to set all this up. .

Upvotes: 2

Bijan
Bijan

Reputation: 8586

You could use this method and add the

$pageTitle = 'Title of Page';

to your content page (i.e. member page)

Upvotes: 0

Related Questions