| | #1 |
| HyperActive Warrior Join Date: 2010 Location: Canada
Posts: 114
Thanks: 0
Thanked 1 Time in 1 Post
|
What I've done is have all my meta tags and title in the "head" page and I include that file on the index page, using php include. That's all good. Now I am a little lost of how I can have different meta tags and titles for each page of the website. Can you tell me the php code to do that? Thanks. |
| | |
| |
| | #2 |
| ɹoıɹɹɐʍ ǝʌıʇɔɐɹǝdʎɥ War Room Member Join Date: 2008 Location: Texas
Posts: 2,138
Thanks: 243
Thanked 453 Times in 382 Posts
Blog Entries: 3 |
Use PHP variables for the changeable tags and set the variable before you call each header, sidebar, footer etc. page1.php Code: dollarsign tag1 = '<meta name="keywords" content="page 1 keywords,internet marketing,affiliate marketing,search engine optimization,ebooks" /> ';
include("includes/header.php"); Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang='en' xml:lang='en' xmlns="http://www.w3.org/1999/xhtml"> <head> <?php echo dollarsign tag1 ;?> /* other common stuff stuff*/ |
|
Robin | |
| |
| | #3 |
| Advanced Warrior War Room Member Join Date: 2006 Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
|
Another way to do it is to put the following code at the top of the "head" page... <?php $currentPage = pathinfo(__FILE__, PATHINFO_FILENAME); ?> That will get the file name of the current page (without the .php extension). So on your home page, for example, it would return "index". Then you can use conditional statements to customize the content on that page, based on what page you're on. For example... <?php if($currentPage == "index"){echo "<title>Home Page</title>";} if($currentPage == "about"){echo "<title>About Us</title>";} if($currentPage == "contact"){echo "<title>Contact Us</title>";} ?> etc. etc. It would probably be better to use switch/case if you have several pages, but you get the idea. |
| | |
| |
| | #4 |
| HyperActive Warrior Join Date: 2010 Location: Canada
Posts: 114
Thanks: 0
Thanked 1 Time in 1 Post
|
Perfect. I will try that.
|
| | |
| |
| | #5 |
| Bananas are Yellow! Registered Member War Room Member Join Date: 2013 Location: Wyoming, PA, USA
Posts: 1,046
Thanks: 2,549
Thanked 1,600 Times in 928 Posts
Blog Entries: 4 | |
| Put MY voice on YOUR video: AwesomeAmericanAudio.com | |
| |
| | #6 | |
| Warrior Member Join Date: 2013 Location: West Dhanmondi, Dhaka,Bangladesh.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
| |
| |
|
| Bookmarks |
| Tags |
| function, include, meta, pages, tags |
| |