Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 23rd Nov 2013, 09:20 AM   #1
HyperActive Warrior
 
man5's Avatar
 
Join Date: 2010
Location: Canada
Posts: 114
Thanks: 0
Thanked 1 Time in 1 Post
Default
How do you include meta tags function on pages?
Share on: 
fb share twitter share gplus share more share

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.

man5 is offline  
Unread 23rd Nov 2013, 09:45 AM   #2
ɹoıɹɹɐʍ ǝʌıʇɔɐɹǝdʎɥ
War Room Member
 
RobinInTexas's Avatar
 
Join Date: 2008
Location: Texas
Posts: 2,138
Thanks: 243
Thanked 453 Times in 382 Posts
Blog Entries: 3
Default
Re: How do you include meta tags function on pages?
Share on: 
fb share twitter share gplus share more share

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");
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*/
The warriorforum software does not seem to allow $ tags in the code example

Robin


...Even if you're on the right track, you'll get run over if you just set there.
RobinInTexas is offline  
Unread 23rd Nov 2013, 10:01 AM   #3
Advanced Warrior
War Room Member
 
Brandon Tanner's Avatar
 
Join Date: 2006
Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
Default
Re: How do you include meta tags function on pages?
Share on: 
fb share twitter share gplus share more share

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.


Brandon Tanner is offline  
Unread 27th Nov 2013, 10:06 AM   #4
HyperActive Warrior
 
man5's Avatar
 
Join Date: 2010
Location: Canada
Posts: 114
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: How do you include meta tags function on pages?
Share on: 
fb share twitter share gplus share more share

Perfect. I will try that.

man5 is offline  
Unread 29th Nov 2013, 12:54 PM   #5
Bananas are Yellow!
Registered Member
War Room Member
 
David Beroff's Avatar
 
Join Date: 2013
Location: Wyoming, PA, USA
Posts: 1,046
Thanks: 2,549
Thanked 1,600 Times in 928 Posts
Blog Entries: 4
Default
Re: How do you include meta tags function on pages?
Share on: 
fb share twitter share gplus share more share

Originally Posted by RobinInTexas View Post

The warriorforum software does not seem to allow $ tags in the code example
You can use the PHP tag in WF to display PHP, and then surround the dollar sign with backslashes, e.g.,

PHP Code:
$keyword = ... 

Put MY voice on YOUR video: AwesomeAmericanAudio.com
David Beroff is offline  
Unread 30th Nov 2013, 03:23 AM   #6
Warrior Member
 
Join Date: 2013
Location: West Dhanmondi, Dhaka,Bangladesh.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: How do you include meta tags function on pages?
Share on: 
fb share twitter share gplus share more share

Originally Posted by man5 View 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.
Hi, thanks for the question and it was mine as well. I have got some important messages through the discussion here.
shariarkhabir179 is offline  
Closed Thread


Bookmarks

Tags
function, include, meta, pages, tags


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 09:54 PM.