2019-04-22, 20:41:07
(2019-02-26, 05:51:41)Carlos Wrote: Insert this in your template, before <?php get_header(); ?>
Code:<?php
$arr =array(
"tag1" => "This is the meta description for tag1",
"tag2" => "This is the meta description for tag2",
"tag3" => "This is the meta description for tag3",
// etc...
);
if (nm_is_tag()) foreach ($arr as $t=>$m) if (nm_is_tag($t)) {$metad=$m; break;}
?>
(If you prefer to have it in a component or a function, a small change would be required.)
Hello, Carlos!
When this code is inserted directly in template everything works just fine. But when I'm trying to use this as a component there is no meta description in the page source code...
The component code:
Code:
<?php
$arr = array(
"сравнение" => "Метаописание для тега сравнение",
"вывески" => "Метаописание для тега вывески",
);
if (nm_is_tag()) foreach ($arr as $t=>$m) if (nm_is_tag($t)) {$metad=$m; break;}
?>
The component in template:
Code:
<head>
//some code here
<?php get_component('tagsmeta'); ?>
<?php nm_get_header(); ?>
//some code here
</head>
What am I doing wrong?