How to add a custom field to a topic
Open your WordPress theme file with your favorite code editor and header.php
find <?php wp_head(); ?>
This code, and add it later:
if (Is_single () | | Is_page ()) { $head = Get_post_meta ($posttrue); if (! Empty ($head)) {?> Echo $head;?> <?php}}?>
The name of the head
custom field is in the code and can be customized;
Add a custom field to an article page or a standalone page
In the WordPress Background Editor page Editor, there is a "custom field" of the small window, enter at the name head
, at the value of the input you want to add to the location of the output code;
After clicking Add Custom field , update your article to enter the values of these custom fields in the place where your subject place the code.
Because it only outputs everything inside "value", you need to enter it in "value"
<type= "Text/javascript">... </ Script >
Or
<type= "Text/css">... </ style >
To output the code.
A little summary of WordPress custom fields
After understanding the above principles, you will find that: WordPress custom fields can not only implement custom page custom JavaScript or CSS, there are many functions can be implemented through custom fields , similar to: add thumbnails to the article, article tips etc...
As for what functionality to implement, or how to implement it, try it with a custom field.
Load the specified JavaScript or CSS code on the WordPress specified page