Php 将模式添加到元<;头>-标签:wordpress
我试图把这个(下面的代码)放到我的wordpress标题中,但当我在浏览器上保存并加载网站时,它并没有显示出来。我已经在一些wordpress主题上看到了这种模式实践,所以它应该是有效的。有人有什么建议吗?是自动wordpress功能改变了这一点Php 将模式添加到元<;头>-标签:wordpress,php,wordpress,Php,Wordpress,我试图把这个(下面的代码)放到我的wordpress标题中,但当我在浏览器上保存并加载网站时,它并没有显示出来。我已经在一些wordpress主题上看到了这种模式实践,所以它应该是有效的。有人有什么建议吗?是自动wordpress功能改变了这一点 <head itemscope="" itemtype="http://schema.org/WebSite"> 在header.php上这样做 <html <?php html_tag_schema(); ?> <
<head itemscope="" itemtype="http://schema.org/WebSite">
在header.php上这样做
<html <?php html_tag_schema(); ?> <?php language_attributes(); ?>>
我希望这一个解决了你的问题它仍然覆盖并重置头标记为它的基本形式你的主题可能有一个覆盖头标记的功能。检查它。在functions.php文件中没有会以这种方式影响的函数。
function html_tag_schema()
{
$schema = 'http://schema.org/';
// Is single post
if(is_single())
{
$type = "Article";
}
// Contact form page ID
else if( is_page(1) )
{
$type = 'ContactPage';
}
// Is author page
elseif( is_author() )
{
$type = 'ProfilePage';
}
// Is search results page
elseif( is_search() )
{
$type = 'SearchResultsPage';
}
// Is of movie post type
elseif(is_singular('movies'))
{
$type = 'Movie';
}
// Is of book post type
elseif(is_singular('books'))
{
$type = 'Book';
}
else
{
$type = 'WebPage';
}
echo 'itemscope="itemscope" itemtype="' . $schema . $type . '"';
}