Home  >  Article  >  Backend Development  >  How WordPress uses the wp_head() function

How WordPress uses the wp_head() function

不言
不言Original
2018-07-06 10:10:306731browse

This article mainly introduces the method of using wp_head() function in WordPress. It has certain reference value. Now I share it with you. Friends in need can refer to

wp_head() Function:

Use this function in WordPress themes to control the tag content between 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1.

To output the head tag part in html through the header.php template file,

wp_head is added to the head tag of most themes () function,

WordPress, themes or plug-ins can add content to the head tag of the website by giving the wp_head function.

Usage:

Please make sure all your pages use 12493c822e68bbb57c539d2976ef876e

The header.php template of many themes supports the wp_head() function by default. If it is not supported, you can add it yourself. The adding method is as follows:

Add 12493c822e68bbb57c539d2976ef876e between 93f0f5c25f18dab9d176bd4f6de5d30e

9c3bca370b5104690d9ef395f2c5f8d1

You can dynamically add code to 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1 when making a plug-in, such as advertising code, etc.

function my_wp_head() {
	echo "<link rel=&#39;stylesheet&#39; href=&#39;../Avada-Child-Theme/css/test.css&#39; type=&#39;text/css&#39; />";
	echo &#39;<meta name="关键字" content="测试内容" />&#39;;	
}
add_action(&#39;wp_head&#39;, &#39;my_wp_head&#39;);

Open any front-end page, right-click "View Source Code" and search for the entered content. If it appears, it means success.

Generally, after the modification is successful, you have to wait for a while to refresh. If you enable cache/use cache plug-ins, you need to clear the cache.

Correspondingly, we will have wp_footer() and wp_sidebar() functions. The usage method is the same as above.

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Introduction to adding fixed fields to articles in wordpress

The above is the detailed content of How WordPress uses the wp_head() function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn