I have problem to add custom metadata to <head></head>
custom page template.
I googled a lot and found to add this to my custom page template
get_header();
some code here ......
load mysql data and put that data in function mySEO()
function mySEO() {
echo '
<title>titleeee</title>
<meta name="description" content="Page description. No longer than 155 characters." />
<meta itemprop="name" content="The Name or Title Here">
<meta itemprop="description" content="This is the page description">
<meta itemprop="image" content="http://www.example.com/image.jpg">
<meta name="twitter:site" content="@publisher_handle">
<meta name="twitter:title" content="Page Title">
<meta name="twitter:description" content="Page description less than 200 characters">
<meta name="twitter:creator" content="@author_handle">
<meta name="twitter:image" content="http://www.example.com/image.html">
<meta property="og:title" content="Title Here" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://www.example.com/" />
<meta property="og:image" content="http://example.com/image.jpg" />
<meta property="og:description" content="Description Here" />
<meta property="og:site_name" content="Site Name, i.e. Moz" />';
}
add_action('wp_head','mySEO');
///some code here...
get_footer();
BUT nothing happens i don’t put anything in head of page… what is problem?
2
Answers
"VEL" responde to my question:
complete answer:
in mypage.php (custom page template) just call function mySEO($title,$description,$image,$url);
You should inlcude the values for the data you need at the top of the PAGE, before the HEADER gets called.
That way, the values will be available to populate the vars included in the HEADER.