php - Dynamicly generated meta tags -
i'm looking simple straightforward solution dynamic meta description in header.php. have far works i'm not satisfied amount of lines, think can done less code , nicely structured xml file.
what have far:
<?php $full_name = $_server['php_self']; $name_array = explode('/',$full_name); $count = count($name_array); $page_name = $name_array[$count-1]; ?> <meta name="description" content=" <?php echo ($page_name=='index.php')?'de nummer 1 in webhosting, wordpress hosting en vps infrastructuur. professionele support gemakkelijk controlepaneel en vele domein extensies':'';?> <?php echo ($page_name=='about.php')?'de nummer 1 in webhosting, wordpress hosting en vps infrastructuur. professionele support gemakkelijk controlepaneel en vele domein extensies':'';?> <?php echo ($page_name=='webhosting.php')?'web hosting':'';?> <?php echo ($page_name=='website_builder.php')?'builder':'';?> <?php echo ($page_name=='wordpress_hosting.php')?'wordpress hosting':'';?> <?php echo ($page_name=='wordpress_builder.php')?'wordpress builder':'';?> <?php echo ($page_name=='domain_search.php')?'zoek je domeinnaam':'';?> <?php echo ($page_name=='domain_transfer.php')?'verhuisje domeinnaam':'';?> <?php echo ($page_name=='contact.php')?'contacteer ons':'';?> <?php echo ($page_name=='support.php')?'support':'';?>" ... />
what looking for
<?php $full_name = $_server['php_self']; $name_array = explode('/',$full_name); $count = count($name_array); $page_name = $name_array[$count-1]; ?> <meta name="description" content=" <?php echo ($page_name==' $page ')?' $content ':'';?> />
$page supposed pagename.php , $content meta description particular page. there 20+ pages dynamically generated php need particular description, keywords,... thinking put descriptions , keywords in xml file , call, depending on page, right content. how this? i'm quite new php , spend last 4 hours trying solve this... tried tutorials nothing suits needs.
there 1 simple solution that.
step 1
create meta.ini file , write file name , meta description below
index.php="your meta description" wordpress-host.php="your meta description"
step 2
<?php $meta = array(); $metafile = 'your dir path/meta.ini'; if(file_exists($langfile)){ $meta = parse_ini_file($metafile); } ?>
step 3
<?php $full_name = $_server['php_self']; $name_array = explode('/',$full_name); $count = count($name_array); $page_name = $name_array[$count-1]; if(isset($meta[$page_name])){ echo '<meta name="description" content="'.$meta[$page_name].'"/>'; } ?>
Comments
Post a Comment