Its difficult to create different title and meta for each page of a website, but we have to add custom meta and title for few pages. Title of inner pages should be created dynamically depend on the page content. Someone please share me a PHP code to create this. thanks in advance
its a bit complicated. u need to use eregi and if statements like this: <?php if (eregi("page1.php",$_SERVER[REQUEST_URI]) //check if page1.php is in the requested url { echo "<meta name='keywords' content='your keywords'><title>Title For page1.php</title>"; } else if (eregi("page2.php",$_SERVER[REQUEST_URI]) //check if page2.php is in the requested url { echo "<meta name='keywords' content='your keywords'><title>Title For page2.php</title>"; } else //if both the page1 and page2 are not in url. { echo "<meta name='keywords' content='your keywords'><title>Title For pagename.php</title>"; } ?> PHP: you need to have some knowledge of php for this. on my site i also use this coding
I think I have to create a php file to include this code, and add some calling fn on the title to call this. Please gimme advice, i am new to php.
Do you have a main header.php file with meta instructions ? What would you want the title to be, maybe some story/news/product ? If you post up what you have including a sample pages php, it would be easier to advise you further.
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: <?php include('get_meta.php'); ?> <title><?php print $title; ?></title> <meta name="keywords" content="<?php print $meta_keywords; ?>"> <meta name="description" content="<?php print $meta_description; ?>"> <?php $database = 'meta_tags.txt'; $meta_db = fopen($database, 'r'); $page = $_SERVER['SCRIPT_NAME']; $page = substr($page, 1); while($data = fgetcsv($meta_db, 9000, '|')) { if($data[0] == $page) { $title = $data[1]; $meta_keywords = $data[2]; $meta_description = $data[3]; } } ?> I would like to whether it is working or not, someone please help me..