{"id":100,"date":"2019-01-18T13:45:24","date_gmt":"2019-01-18T05:45:24","guid":{"rendered":"https:\/\/www.hlzhy.com\/?p=100"},"modified":"2019-01-18T14:01:58","modified_gmt":"2019-01-18T06:01:58","slug":"wordpress%e6%96%87%e7%ab%a0%e5%88%97%e8%a1%a8%e6%b7%bb%e5%8a%a0%e7%bc%a9%e7%95%a5%e5%9b%be%ef%bc%88%e6%97%a0%e6%8f%92%e4%bb%b6%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.hlzhy.com\/?p=100","title":{"rendered":"WordPress\u6587\u7ae0\u5217\u8868\u6dfb\u52a0\u7f29\u7565\u56fe\uff08\u65e0\u63d2\u4ef6\uff09"},"content":{"rendered":"\n<p>\u8fd9\u51e0\u5929\u90fd\u5728\u6298\u817e\u8fd9\u4e2a\u535a\u5ba2\uff0c\u6362\u4e86\u4e2a\u65b0\u4e3b\u9898\u611f\u89c9\u8fd8\u4e0d\u9519\uff0c\u5c31\u662f\u6587\u7ae0\u5217\u8868\u6ca1\u6709\u7f29\u7565\u56fe\u8ba9\u6211\u611f\u89c9\u4e0d\u662f\u592a\u559c\u6b22\uff0c\u4e2a\u4eba\u6bd4\u8f83\u559c\u6b22\u7b80\u4e66\u7684\u90a3\u79cd\u98ce\u683c\uff0c\u6240\u4ee5\u5c31\u53bb\u627e\u4e86\u4e00\u4e9b\u8d44\u6599\u81ea\u5df1\u4eff\u7167\u7740\u7b80\u4e66\u7684\u98ce\u683c\u6539\u4e86\u4e00\u4e0b\u3002\u4fee\u6539\u7684\u6b65\u9aa4\u4e5f\u6bd4\u8f83\u7b80\u5355\uff0c\u8fd9\u91cc\u5c31\u505a\u4e00\u4e0b\u8bb0\u5f55\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.hlzhy.com\/wp-content\/uploads\/2019\/01\/image-1-973x1024.png\" alt=\"\" class=\"wp-image-101\" width=\"427\" height=\"448\" srcset=\"https:\/\/www.hlzhy.com\/wp-content\/uploads\/2019\/01\/image-1-973x1024.png 973w, https:\/\/www.hlzhy.com\/wp-content\/uploads\/2019\/01\/image-1-285x300.png 285w, https:\/\/www.hlzhy.com\/wp-content\/uploads\/2019\/01\/image-1-768x808.png 768w, https:\/\/www.hlzhy.com\/wp-content\/uploads\/2019\/01\/image-1.png 1604w\" sizes=\"(max-width: 427px) 100vw, 427px\" \/><figcaption>\u6548\u679c\u56fe<br><\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e00\u6b65<\/h3>\n\n\n\n<p>\u5728\u4e3b\u9898\u6587\u4ef6 \u6837\u5f0f\u8868(style.css)\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e0b\u9762\u7684CSS\u3002\u6211\u8fd9\u662f\u4eff\u7167\u7b80\u4e66\u7684\u6837\u5f0f\u5199\u7684\uff0c\u4f60\u4e5f\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u66f4\u6539\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * \u4eff\u7167\u7b80\u4e66\u7684\u6837\u5f0f\n *\/\n#thumbnail{\n\tmargin:-5px 5px 5px 5px;\n\twidth:115px;height:100px;\n\tborder-radius:5px;\n\tborder:1px solid #eee;\n\tfloat:right;\n\toverflow:hidden;\n\ttext-align:center;\n} \n#thumbnail img{\n\tmax-height:100px;\n\tmax-width:180px;\n\tmin-height:100%;\n\tmin-width:100%;\n\tmargin: 0 -100%;\n} <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e8c\u6b65<\/h3>\n\n\n\n<p>\u5728\u51fd\u6570\u6a21\u677f(functions.php)\u6587\u4ef6\u4e2d\u7684<code>&lt;?php<\/code> \u548c <code>?&gt;<\/code>\u5185\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u3002<\/p>\n\n\n\n<ul><li><code>soImages<\/code>&nbsp;&nbsp;\u662f\u83b7\u53d6\u6587\u7ae0\u5185\u56fe\u7247\u7684\u6b63\u5219\uff0c\u5982\u679c\u6709\u5176\u4ed6\u9700\u6c42\uff0c\u6539\u6210\u5bf9\u5e94\u7684\u6b63\u5219\u5373\u53ef<\/li><li>\u4e0b\u9762\u6ce8\u91ca\u6389\u7684\u4ee3\u7801\u662f\u5f53\u6587\u7ae0\u5185\u6ca1\u6709\u56fe\u7247\u65f6\u63d0\u4f9b\u4e00\u5f20\u9ed8\u8ba4\u56fe\u7247\u3002\u6211\u8fd9\u91cc\u628a\u5b83\u6ce8\u91ca\u6389\uff0c\u5982\u679c\u6587\u7ae0\u5185\u6ca1\u6709\u56fe\u7247\u6211\u5c31\u4e0d\u663e\u793a\u56fe\u7247\uff0c\u8bfb\u53d6\u7684\u662f\u6211\u5f53\u524d\u4e3b\u9898\u4e0b<code>\/assets\/images<\/code>\u8def\u5f84\u7684thumbnail.jpg\u56fe\u7247\u6587\u4ef6\uff0c\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u4fee\u6539\u3002<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * \u9996\u9875\u6587\u7ae0\u56fe\u7247\n *\n * @since ZHY\n *\/\nfunction thumbnail_img($soContent){ \n\t$soImages = '\/&lt;img.*?src=[\\\"|\\']?(.*?)[\\\"|\\']?\\s.*?>\/i';\n\tpreg_match_all( $soImages, $soContent, $thePics ); \n\t$allPics = count($thePics[0]); \n\tif( $allPics > 0 ){ \n\t\techo \"&lt;span id='thumbnail'>\"; \n\t\techo $thePics[0][0]; \n\t\techo '&lt;\/span>'; \n\t} else { \n\t\t\/**\n\t\t * \u6253\u5f00\u4ee5\u4e0b\u6ce8\u91ca\u4ee3\u7801\uff0c\u5f53\u6587\u7ae0\u6ca1\u6709\u56fe\u7247\u65f6\u63d0\u4f9b\u4e00\u5f20\u9ed8\u8ba4\u56fe\u7247\u3002\n\t\t *\/\n\t\t\/\/ echo \"&lt;span id='thumbnail'>\"; \n\t\t\/\/ echo \"&lt;img src='\"; \n\t\t\/\/ echo bloginfo('template_url'); \n\t\t\/\/ echo \"\/assets\/images\/thumbnail.jpg'>&lt;\/span>\"; \n\t} \n} <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e09\u6b65<\/h3>\n\n\n\n<p>\u8fd9\u4e00\u6b65\u5e76\u4e0d\u662f\u7edd\u5bf9\u7684\u6309\u7167\u6211\u7684\u6765\uff0c\u6839\u636e\u4e0d\u540c\u7684\u4e3b\u9898\u6709\u6240\u4e0d\u540c\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u7684\u4e3b\u9898\u7684\u5217\u8868\u5c55\u793a\u7684\u662f\u5185\u5bb9\u4fe1\u606f\uff0c\u5373<code>the_content<\/code>\uff0c\u5219\u5728<code>the_content();<\/code>\u4ee3\u7801\u4e4b\u524d\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801\u3002<\/p>\n\n\n\n<p>\u4ee5\u6211\u5f53\u524d\u4e3b\u9898\u4e3a\u4f8b\uff1a\u6211\u5f53\u524d\u4e3b\u9898\u7684\u6587\u7ae0\u5217\u8868\u5c55\u793a\u7684\u662f\u6458\u8981\u4fe1\u606f\uff0c\u5373\u5728content.php\u6587\u4ef6\u5185\u627e\u5230<code>the_excerpt();<\/code>&nbsp;\u4ee3\u7801\uff0c\u5728\u5b83\u4e4b\u524d\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>thumbnail_img($post->post_content); <\/code><\/pre>\n\n\n\n<p>\u5b8c\u6210\u8fd9\u4e09\u6b65\u7f29\u7565\u56fe\u5c31\u5df2\u7ecf\u53ef\u4ee5\u663e\u793a\u51fa\u6765\u4e86\uff0c\u5982\u679c\u6ca1\u663e\u793a\u51fa\u6765\uff0c\u53ef\u80fd\u662f\u6d4f\u89c8\u5668\u7f13\u5b58\u6240\u81f4\uff0c\u6e05\u7406\u7f13\u5b58\u5237\u65b0\u754c\u9762\u5373\u53ef\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Chrome\u6e05\u7406\u6d4f\u89c8\u5668\u7f13\u5b58<\/h4>\n\n\n\n<ul><li>\u6253\u5f00\u8981\u6e05\u7406\u7f13\u5b58\u7684\u9875\u9762\u6309F12\uff08Mac\uff1a\u2325\u2318+I\uff09\u6253\u5f00\u5f00\u53d1\u8005\u5de5\u5177\u754c\u9762<\/li><li>\u9009\u62e9Network \u5e76\u52fe\u9009 Disable cache<\/li><li>\u4e0d\u8981\u5173\u95ed\u5f00\u53d1\u8005\u5de5\u5177\u754c\u9762\uff0c\u5237\u65b0\u754c\u9762\u5373\u81ea\u52a8\u6e05\u9664\u7f13\u5b58\u3002<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u8fdb\u4e00\u6b65\u8c03\u6574<\/h3>\n\n\n\n<p>\u6ce8\u610f\uff1a\u4ee5\u4e0b\u65b9\u6cd5\u4ec5\u5728\u5217\u8868\u5c55\u793a\u7684\u4e3a<strong>\u6458\u8981<\/strong>\u65f6\u624d\u9002\u7528<\/p>\n\n\n\n<p>\u6dfb\u52a0\u7f29\u7565\u56fe\u540e\u6458\u8981\u6587\u5b57\u53ef\u7528\u5bbd\u5ea6\u5c31\u53d8\u77ed\u4e86\uff0c\u5c31\u53ef\u80fd\u4f1a\u51fa\u73b0\u6587\u5b57\u884c\u6570\u8fc7\u591a\u4e0d\u7f8e\u89c2\u7684\u60c5\u51b5\uff0c\u6b64\u65f6\u6211\u4eec\u53ef\u4ee5\u5728\u6a21\u677f\u51fd\u6570&nbsp;(functions.php)\u6587\u4ef6\u5185\u627e\u5230<code>excerpt_length<\/code>\u51fd\u6570\uff0c\u4fee\u6539\u5176return\u7684\u5b57\u6570\u5373\u53ef\u3002<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u51e0\u5929\u90fd\u5728\u6298\u817e\u8fd9\u4e2a\u535a\u5ba2\uff0c\u6362\u4e86\u4e2a\u65b0\u4e3b\u9898\u611f\u89c9\u8fd8\u4e0d\u9519\uff0c\u5c31\u662f\u6587\u7ae0\u5217\u8868\u6ca1\u6709\u7f29\u7565\u56fe\u8ba9\u6211\u611f\u89c9\u4e0d\u662f\u592a\u559c\u6b22\uff0c\u4e2a\u4eba\u6bd4\u8f83\u559c\u6b22\u7b80\u4e66\u7684\u90a3\u79cd\u98ce\u683c\uff0c\u6240\u4ee5\u5c31\u53bb\u627e\u4e86\u4e00\u4e9b\u8d44\u6599\u81ea &hellip; <a href=\"https:\/\/www.hlzhy.com\/?p=100\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">WordPress\u6587\u7ae0\u5217\u8868\u6dfb\u52a0\u7f29\u7565\u56fe\uff08\u65e0\u63d2\u4ef6\uff09<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[10],"_links":{"self":[{"href":"https:\/\/www.hlzhy.com\/index.php?rest_route=\/wp\/v2\/posts\/100"}],"collection":[{"href":"https:\/\/www.hlzhy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hlzhy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hlzhy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hlzhy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=100"}],"version-history":[{"count":4,"href":"https:\/\/www.hlzhy.com\/index.php?rest_route=\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":105,"href":"https:\/\/www.hlzhy.com\/index.php?rest_route=\/wp\/v2\/posts\/100\/revisions\/105"}],"wp:attachment":[{"href":"https:\/\/www.hlzhy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hlzhy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hlzhy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}