Load the specified JavaScript or CSS code on the WordPress specified page

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.