Top

Dynamic Title and Meta Tags

Please Register to submit score.
Average Score  4.0
Scores Submitted  2
Date Added  Dec 10, 2007
Last Updated  Dec 10, 2007
Tags  dynamic  keywords  meta  php  tags  title 

Introduction

This is a very simple PHP snippet that will set $title, $meta_keywords and $meta_description for use in your page header. You'll need to create meta_tags.txt which will use this format:

page_name.html|page title|meta tags|meta description
page_name2.html|page title2|meta tags for page 2|meta description for page 2

To use the code either save it at the top of your header file or save it as get_meta.php and add this line of code to your header:

Code:
<?php include('get_meta.php'); ?>

You can reference the $title, $meta_keywords and $meta_description variables in your header like this:

Code:
<title><?php print $title; ?></title>
<meta name="keywords" content="<?php print $meta_keywords; ?>">


Grab the Code

Comments

  (4)  RSS
sean
Comments: 111
 
Posted on Dec 10, 2007 5:36 am
simple, yet nice way to accomplish something that could be respectivly more complex
M[n]M
Comments: 94
 
Posted on Dec 10, 2007 11:32 am
nice, i like this one
alanhogan
Comments: 5
 
Posted on Dec 18, 2007 6:24 pm
I don't know, I'm new here but this snippet seems pretty worthless except for a few special cases. I would like to say this site is a great concept and pretty good implementation though. I would like to see an easy way to see most-used and highest-rated snippets in any language, though!
Hawkee
Comments: 559
 
Posted on Jan 8, 2008 7:10 pm
Thanks for the feedback alan. This snippet was a request by a friend to be used as a learning tool, but some others who are new to site building may find it useful.

You can see the highest rated snippets in every category by choosing to sort by score. You can also see the highest rated snippets for any search or tag by using the same sort. We'll also be implementing a newer way to find more current, highly rated snippets in the near future.

Please Register or Login to start posting comments.
Bottom