Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将模式添加到元<;头>-标签:wordpress_Php_Wordpress - Fatal编程技术网

Php 将模式添加到元<;头>-标签:wordpress

Php 将模式添加到元<;头>-标签:wordpress,php,wordpress,Php,Wordpress,我试图把这个(下面的代码)放到我的wordpress标题中,但当我在浏览器上保存并加载网站时,它并没有显示出来。我已经在一些wordpress主题上看到了这种模式实践,所以它应该是有效的。有人有什么建议吗?是自动wordpress功能改变了这一点 <head itemscope="" itemtype="http://schema.org/WebSite"> 在header.php上这样做 <html <?php html_tag_schema(); ?> <

我试图把这个(下面的代码)放到我的wordpress标题中,但当我在浏览器上保存并加载网站时,它并没有显示出来。我已经在一些wordpress主题上看到了这种模式实践,所以它应该是有效的。有人有什么建议吗?是自动wordpress功能改变了这一点

<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 . '"';
}