How WordPress implements Gzip compression

Everyone knows,Compression affects the overall loading speed of the website andSEOA significant improvement,But many people use plugins orcdnwhich providedGZIPDecompression,This may make the overall optimization of the website not obvious,It is inevitable if there are some bugs in the plug-in. About using codeGZIPcompression: 1、Put in the template directorystyle.cssMake a copy,namedstyle.css.php,Followed bystyle.css.phpAdd this sentence at the top: […]

WordPress gets statistics on the number of images in an article

as far as I knowWordPressThere is no function to count the number of pictures in the article,So if you want to get the total number of all pictures in the article, you can only add by yourselfWordPressCode to achieve。 This feature is not difficult to achieve, Just a few lines of code, There are many […]

WordPress batch change domain names in articles

This tutorial is packaged and replaced for my entire site,But it can also be used to change the domain name path when you move. such as Original domain name Replace in bulk Whole station packing download 2GB Start of the tutorial Entry path: themes/theme/functions.php Add the following code   function replace_text_wps($text){$replace = array(‘https://Old […]

How to prevent articles with duplicate titles from being published?

Prevent publication of articles with the same title  I usually post articles for external links or something,The webmasters are busy,Sometimes articles with the same title are published,At this time, you can use this string of codes to make a simple prediction.。 note:Recommend to use under traditional editor。 When you publish the article,Check for duplicate article […]

WordPress non-regular get the first image of the article

Circulated onlineWordPressThe method of obtaining the first picture of the article as a thumbnail is achieved by using regular matching crawling,code show as below: function catch_that_image() { global $post, $posts; $first_img = ”; ob_start(); ob_end_clean(); $output = preg_match_all(‘/<img.+src=[‘”]([^'”]+)[‘”].*>/i’, $post->post_content, $matches); $first_img = $matches[1][0]; if(empty($first_img)){ $first_img = ‘/images/default.jpg’; } return $first_img; } Some people say that […]

Enable the font rendering of the browser

Font rendering in the browser stayabout:configSearch incleartype,The following items were found gfx.font_rendering.cleartype_params.gamma gamma value 1000 reach 2200 gfx.font_rendering.cleartype_params.enhanced_contrast Font contrast(What I set up here is200,Set according to personal preference,没发现最大value是多少) gfx.font_rendering.cleartype_params.cleartype_level cleartypeGrade 0 reach 100 gfx.font_rendering.cleartype_params.pixel_structure 0 = flat, 1 = RGB, 2 = BGR Liquid crystalRGB,choice1 gfx.font_rendering.cleartype_params.rendering_mode 0 = default, 1 = aliased, 2 = […]

Manually open WordPress site maintenance mode

In an updater or plug-in,WordPressThe front end will show that it is in maintenance mode,If you want to temporarily enable maintenance mode,Let users know that your site is under maintenance,It can be realized by the following code。 openWordPressSite maintenance mode Add the following code to the current topic function templatefunctions.phpin: function zm_maintenancemode() { if ( […]