WordPress calls the media library component wp.media to upload pictures, videos, documents and other media files

WordPress theme or plug-in application development often requires uploading function of media files such as pictures, videos, documents, etc. If developers write media upload components independently, they need to spend a lot of time and effort. However, by calling the media library components provided with WordPress, they can achieve twice the result with half the effort. Only simple js code can be written to have a powerful media upload function. Wp.media code parameter var mediaObj=wp.media ({frame: 'select',//Select the media type to call the media library. You can select, post, image, audio, video, and select s
WordPress Tutorial 965 ℃

The function is_active_widget used by WordPress to determine whether the specified appearance widget is enabled

The WordPress function is_active_widget() detects whether a visual gadget (such as a search gadget) is enabled (added to the sidebar) after the gadget is initialized. If the gadget is enabled, it returns true or the ID of the sidebar where the gadget is located. If the gadget is not enabled, it returns false or the ID of the sidebar where the gadget is located is empty. It should be noted that the test shows that this function is only effective for old gadgets, and does not support block gadgets. Function code is_active_widget (call | false $callback=fa
WordPress Tutorial 1075 ℃

WordPress code hook jpeg_quality for modifying the compression quality of uploaded JPEG images

Many people may not have noticed that WordPress has always compressed the image quality of uploaded JPEG formats (such as. jpeg and. jpg) by default. Before WordPress 4.5, the image quality will be compressed to 90%. After WordPress 4.5, the image quality will be compressed to 82%. This is to reduce the image size and optimize the loading speed. But not everyone wants the uploaded image to be compressed, because the compression quality means that the uploaded image will be blurred or distorted. Of course, some people think that the image quality is not compressed low enough and want to compress it smaller. Perhaps the WordPress official also took these situations into consideration, so it also provided modifications
WordPress Tutorial 1332 ℃

How to use the function next_post_link() in Wordpress to get the next article

The next_post_link() function is one of the commonly used wordpress functions. It is used to display the next article link adjacent to the current article. The previous article and the next article are almost the article page elements that will be added to the current website, which is said to be conducive to SEO optimization. This content blog shares the tutorials and methods for using the next_post_link() function in the next article. The function structure parameter describes the format of the $format - (string) (optional) link anchor. The default is' «% link '. Default value: '% link»'$ Link - (String) (Optional) The text of the link. Silence
WordPress Tutorial 1377 ℃

Wordpress gets the ID function get_queried_object_id() of the current category/tag/article/taxonomy/article type

When making WordPress themes or plug-in functions, it is often necessary to obtain the current classification ID, current tag ID, current article ID, current custom taxonomy classification ID, current custom article type article ID, and current single page ID. WordPress can obtain ID in many ways, such as name, alias, global variable, etc, In fact, the get_queried_object_id() function has been added in WordPress 3.1.0. It is very simple to directly obtain the ID of the current page. Function code get_queried_object_id() retrieves the current query pair
WordPress Tutorial 2924 ℃

Introduction to the common global variable $post code of wordpress

In the development process of wordpress plug-ins or theme applications, global variables are a must to understand. The following is the wordpress global variable $post, which is often used. The global variable $post is used to obtain the ID, title, author, publishing time and content information of the current article. In practical applications, such as when writing a function to extract the first picture of article content, You can use the $post global variable. Variable code global $post; echo $post->ID; // Article ID echo $post ->post_author// Article author ID echo $p
WordPress Tutorial 2951 ℃

Illustrate the difference between WordPress Action Hook and Filter Hook and use the functions add_filter() and add_filter()

After understanding the concept and action mechanism of the WordPress hook hook, the next step is to know how to use the hook to realize the functions you need. WordPress has two kinds of hooks, namely, "Action Hook" and "Filter Hook", which correspond to the functions add_filter() and add_filter(), respectively. The wp_head and wp_footer examples above both belong to Action Hook. In fact, they can be regarded as the same thing, but the Filter has a little different features. A...
WordPress Tutorial 2001 ℃
 Simple and understandable description of the concept and action mechanism of WordPress hook

Simple and understandable description of the concept and action mechanism of WordPress hook

Hook is something that is often or surely used in the development of WordPress theme plug-in applications. Therefore, if you want to learn how to develop WordPress themes or plug-ins, WordPress Hook is one of the required contents. Generally, novices who are new to WordPress Hook may be a little confused or even confused about the operation principle of Hook. To this end, Blog Bar today shares an explanation of the principle of WordPress Hot mechanism
WordPress Tutorial 1756 ℃

WordPress gets the information function get_next_post() of the next article in the current article

The wordpress function get_next_post() is often placed on the article content page to determine whether there is a next article or restrict the return of the next article with the same classification as the current article, and to obtain the ID, title, content, summary, author and other data information of the next article. It is the sibling function of the function get_previous_post() that obtains the information of the previous article. (More...)
WordPress Tutorial 2103 ℃

WordPress gets the information function get_previous_post() of the previous article of the current article

The wordpress function get_previous_post() is often placed on the article content page to determine whether there is a previous article or restrict the return of the previous article with the same classification as the current article. In fact, the get_previous_post() function can also obtain the content information of the previous article, such as the ID, title, content, summary, and author of the previous article. (More...)
WordPress Tutorial 1665 ℃

Wordpress symbol tag code escapes to the function esc_html () of HTML entity

Esc_html () is one of the commonly used wordpress functions in the development of wordpress theme plug-ins. Its function is to escape various characters into HTML entities, such as less than (<), greater than (>), and (&), double quotation marks (""), single quotation marks (''), etc. If the characters are already HTML entities, they will not be escaped. Through this function, you can output a complete string, even if the string has an HTML tag, such as "<strong>Bold Font</strong>", rather than just the four bold characters "Bold Font". (More...)
WordPress Tutorial 1650 ℃

The function wp_get_attachment_metadata() for wordpress to obtain the metadata of media attachment image

In Wordpress, you can use the wp_get_attachment_metadata() function to obtain the metadata of the specified attachment ID, such as the width and height of the attachment, the path of the uploaded file, and the aperture, IOS, shutter and other metadata of the photo image. It is a very useful wordpress function for WordPress websites that want to do pictures, photography, and image material types. (More...)
WordPress Tutorial 1016 ℃

Wordpress gets the code specifying the size of the attachment file

When using WordPress to develop download websites or other material websites, it may be necessary to display the byte size of the attachment file. Although the size of the file is displayed when viewing the details of the attachment in the WordPress background media, it does not seem to directly provide a field to call this parameter, so you need to write your own code. The code is also very simple, The following is the code compiled by the blog bar. (More...)
WordPress Tutorial 1276 ℃