Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.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 如何更改WP内部的HTML结构<;头>;_Php_Html_Wordpress_Xhtml_Html Head - Fatal编程技术网

Php 如何更改WP内部的HTML结构<;头>;

Php 如何更改WP内部的HTML结构<;头>;,php,html,wordpress,xhtml,html-head,Php,Html,Wordpress,Xhtml,Html Head,我正在清理一些HTML代码,我希望有一个如下所示的HTML结构: <!DOCTYPE html> <html > <head> <title>...</title> <meta name="description" content="..." /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> ... ... ...

我正在清理一些HTML代码,我希望有一个如下所示的HTML结构:

<!DOCTYPE html>
<html >
<head>
<title>...</title>
<meta name="description" content="..." />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> ...

...
...
所以基本上我希望“title”和“meta description”出现在“head”标签的后面。 网站正在运行Wordpress,所以我已经查看了general-template.php-文件,但并没有找到“元描述”的输出


我是否需要安装元描述插件(例如Yoast),然后更改wp_head()的位置?或者我是否需要以某种方式编辑wp_head()函数?

编辑您的主题标题.php,简单:)确保
位于所有主题标题下方(如果它存在的话…

只要确保
位于头部标记之间即可。这样,当你安装Yoast SEO或任何插件时,它就能够插入正确的东西。

有很多清洁头解决方案,比如添加挂钩来清洁大多数worpress默认功能(RSD、RSS链接等)。在theme functions.php中尝试以下挂钩:

/*remove actions to clean wp_head*/
remove_action('wp_head', 'wlwmanifest_link'); // remove wlwmanifest.xml (needed to support windows live writer)
remove_action('wp_head', 'wp_generator'); // remove wordpress version
remove_action( 'wp_head', 'wp_resource_hints', 2 );//remove dns prefech
remove_action('wp_head', 'rsd_link'); // remove really simple discovery link
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0 ); // remove shortlink

remove_action( 'wp_head', 'print_emoji_detection_script', 7 );  // remove emojis
remove_action( 'wp_print_styles', 'print_emoji_styles' );   // remove emojis

remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); // remove the / and previous post links

remove_action('wp_head', 'feed_links', 2); // remove rss feed links
remove_action('wp_head', 'feed_links_extra', 3); // removes all extra rss feed links

remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); // remove the REST API link
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); // remove oEmbed discovery links
remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); // remove the REST API link from HTTP Headers

remove_action( 'wp_head', 'wp_oembed_add_host_js' ); // remove oEmbed-specific javascript from front-end / back-end

remove_action('rest_api_init', 'wp_oembed_register_route'); // remove the oEmbed REST API route
remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10); // don't filter oEmbed results
您还可以将此代码段包装到函数中,使其在主题设置后或初始化后工作


wp_head()之后可以隐藏其他标记,如
charset
http equiv
属性;header.php中的操作。另外,请查看wp includes模板文件夹文件,以定位wp_head()操作并删除/注释不必要的操作

可能是SEO信徒认为,如果内容不是按特定顺序排列,搜索引擎机器人无法读取。你在这上面浪费时间吗?检查主题文件夹中的header.php。