0
votes

I have single pages with no header/footer. They just have the content for each page in.

My index.php page has the template around including the page title, but I want to set each page title within each page.

In the index.php page, I include the page file in the <body> tag

3

3 Answers

1
votes

I have an alternative method might be useful.

Don't close the head tag in your index file, then in you content files set title using tag and close the head tag.

something like

index.php

<html>
<head>
<!--links--->
<?php require "content.php";?>
</html>

content.php file:

<title>YOUR TITLE</title>
</head>
<body>
<!--your data-->
</body>
1
votes

Another solution

you can do this

index.php

<html>
<head>
<title><?php title_func(); ?></title>
</head>

<body>
 require "content.php";
</body>
</html>

content.php Just make this function anywhere

 <?php 
    function title_func(){
        echo "title here";
    } 
?>
0
votes

You can use javascript or jquery to do that. First, give the title tage an id

<title id='page_title'>My Page</title>

Then on every page, just at the put something like:

<script>
    var new_page_title= 'My New Title'
</script>

Lastly in the footer part of your template, simply use javascript or jquery to change the name:

// javascript
document.getElementById ('page_title').innerHTML = new_page_title;

// jquery
$ ('#page_title').html (new_page_title);

EDIT

What @Purushotam says can work as well