{"id":30925,"date":"2024-11-25T16:56:00","date_gmt":"2024-11-25T08:56:00","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30925\/"},"modified":"2024-11-25T16:56:00","modified_gmt":"2024-11-25T08:56:00","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8wordpress%e5%86%85%e7%bd%ae%e5%9b%be%e7%89%87%e4%bb%93%e5%ba%93%e5%88%b6%e4%bd%9c%e7%bc%a9%e7%95%a5%e5%9b%be","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30925\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528WordPress\u5185\u7f6e\u56fe\u7247\u4ed3\u5e93\u5236\u4f5c\u7f29\u7565\u56fe"},"content":{"rendered":"<p style=\"text-align: center\"><strong><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5e13e9625a292622.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528WordPress\u5185\u7f6e\u56fe\u7247\u4ed3\u5e93\u5236\u4f5c\u7f29\u7565\u56fe\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528WordPress\u5185\u7f6e\u56fe\u7247\u4ed3\u5e93\u5236\u4f5c\u7f29\u7565\u56fe\u63d2\u56fe\" \/><\/strong><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528\u5185\u7f6e\u56fe\u7247\u4ed3\u5e93\u5236\u4f5c\u7f29\u7565\u56fe\uff1f<\/strong><\/p>\n<p>WordPress \u4e0d\u4ec5\u662f\u535a\u5ba2, \u5f88\u591a\u65f6\u5019 WordPress \u8fd8\u88ab\u7528\u4f5c\u4e3a CMS (\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf). \u535a\u4e3b\u4eec\u559c\u6b22\u4e3a\u6bcf\u4e2a\u6587\u7ae0\u52a0\u4e0a\u7edf\u4e00\u5927\u5c0f\u7684\u7f29\u7565\u56fe, \u5c24\u5176\u662f\u4fe1\u606f\u7c7b\u5e73\u53f0. \u5176\u4e2d\u6bd4\u8f83\u5e38\u7528\u7684\u5904\u7406\u529e\u6cd5\u662f\u7528 custom field \u5411\u6587\u7ae0\u63d2\u5165\u56fe\u7247, \u901a\u8fc7\u4e0a\u4f20\u5927\u5c0f\u4e00\u81f4\u7684\u5c0f\u56fe\u6216\u8005\u4f7f\u7528 phpThumb \u7b49\u5de5\u5177\u751f\u6210\u7f29\u7565\u56fe.&nbsp;<\/p>\n<p>&nbsp;\u63a8\u8350\uff1a\u300a\u300b<\/p>\n<p>2.7 \u5f00\u59cb, WordPress \u5927\u5e45\u63d0\u5347\u591a\u5a92\u4f53\u529f\u80fd, \u8d8a\u6765\u8d8a\u591a\u4eba\u4f7f\u7528 WP \u7684\u5185\u7f6e\u56fe\u7247\u4ed3\u5e93. \u5bf9\u8fd9\u4e9b\u7528\u6237\u6765\u8bf4, \u5236\u4f5c\u7f29\u7565\u56fe\u53d8\u5f97\u5e76\u4e0d\u90a3\u4e48\u56f0\u96be, \u5728\u4e0a\u4f20\u56fe\u7247\u7684\u65f6\u5019\u5c31\u4f1a\u9ed8\u8ba4\u751f\u6210 150&#215;150 \u89c4\u683c\u7684\u5c0f\u56fe (\u5982\u679c\u56fe\u7247\u9ad8\u5ea6\/\u5bbd\u5ea6\u4e0d\u8db3 150px, \u4f7f\u7528\u539f\u9ad8\u5ea6\/\u5bbd\u5ea6). \u90a3\u6211\u4eec\u53ef\u4ee5\u5145\u5206\u5229\u7528\u8fd9\u4e2a\u529f\u80fd, \u5728\u6587\u7ae0\u5217\u8868\u4e0a\u52a0\u4e0a\u8fd9\u4e2a\u56fe\u7247\u4f5c\u4e3a\u7f29\u7565\u56fe. \u8fd9\u6837\u5904\u7406\u5404\u6709\u5229\u5f0a, \u597d\u5904\u662f\u7b80\u5355, \u667a\u80fd (\u4e0d\u7528\u6bcf\u6b21\u8f93\u5165\u7f29\u7565\u56fe), \u574f\u5904\u662f\u6d88\u8017\u670d\u52a1\u5668\u6d41\u91cf.&nbsp;<\/p>\n<p>Okay, \u73b0\u5728\u8981\u505a\u7684\u5c31\u662f\u63d0\u53d6\u4e0a\u4f20\u751f\u6210\u7684\u5c0f\u56fe\u7247, \u5e76\u653e\u7f6e\u5728\u6587\u7ae0\u7684\u9002\u5f53\u4f4d\u7f6e. \u6211\u521b\u5efa\u4e86\u4e00\u4e2a\u6587\u4ef6 thumb.php, \u56fe\u7247\u83b7\u53d6\u548c\u8c03\u7528\u4e00\u8d77\u5904\u7406, \u6587\u4ef6\u5185\u5bb9\u5982\u4e0b.&nbsp;<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>&lt;?php  \n$args = array( \n&#039;numberposts&#039; =&gt;&nbsp;1,&nbsp;\n'order'=&amp;gt;&nbsp;'ASC',&nbsp;\n'post_mime_type'&nbsp;=&amp;gt;&nbsp;'image',&nbsp;\n'post_parent'&nbsp;=&amp;gt;&nbsp;$post-&amp;gt;ID,&nbsp;\n'post_status'&nbsp;=&amp;gt;&nbsp;null,&nbsp;\n'post_type'&nbsp;=&amp;gt;&nbsp;'attachment'&nbsp;\n);&nbsp;\n$attachments&nbsp;=&nbsp;get_children($args);&nbsp;\n$imageUrl&nbsp;=&nbsp;'';&nbsp;\nif($attachments)&nbsp;{&nbsp;\n$image&nbsp;=&nbsp;array_pop($attachments);&nbsp;\n$imageSrc&nbsp;=&nbsp;wp_get_attachment_image_src($image-&amp;gt;ID,&nbsp;'thumbnail');&nbsp;\n$imageUrl&nbsp;=&nbsp;$imageSrc[0];&nbsp;\n}&nbsp;else&nbsp;{&nbsp;\n$imageUrl&nbsp;=&nbsp;get_bloginfo('template_url')&nbsp;.&nbsp;'\/img\/default.gif';&nbsp;\n}&nbsp;\n?&amp;gt;&nbsp;\n&lt;a&gt;\"&amp;gt;@@##@@\"&nbsp;alt=\"&lt;?php  the_title(); ?&gt;\"&nbsp;width=\"150\"&nbsp;height=\"150\"&nbsp;\/&amp;gt;&lt;\/a&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u53bb\u627e\u7b2c\u4e00\u4e2a\u4e0a\u4f20\u7684\u56fe\u7247\u7f29\u7565\u56fe (\u5982\u679c\u7b2c\u4e00\u4e2a\u56fe\u7247\u88ab\u5220\u9664, \u5219\u627e\u7b2c\u4e8c\u4e2a\u7684, \u5982\u6b64\u7c7b\u63a8&#8230;), \u5982\u679c\u627e\u4e0d\u5230\u4efb\u4f55\u4e0a\u4f20\u56fe\u7247\u5219\u4f7f\u7528\u9ed8\u8ba4\u56fe\u7247&nbsp;<\/p>\n<p>\u7136\u540e\u5728\u6587\u7ae0\u5217\u8868 index.php, \u5b58\u6863\u9875\u9762 archive.php \u548c\u641c\u7d22\u9875\u9762 search.php \u4e2d\u8c03\u7528, \u8c03\u7528\u4ee3\u7801\u5982\u4e0b.&nbsp;<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>&lt;?php  include(&#039;thumb.php&#039;); the_content(&#039;Read More...&#039;); ?&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u662f\u628a\u56fe\u7247\u653e\u5728\u6587\u7ae0\u5185\u5bb9\u524d\u9762, \u56fe\u7247\u5982\u4f55\u6446\u653e\u9700\u8981\u7528 CSS \u8c03\u6574\u4e00\u4e0b\u5e03\u5c40, \u8fd9\u91cc\u5c31\u4e0d\u591a\u8bf4\u4e86.&nbsp;<\/p>\n<p><img> <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528WordPress\u5185\u7f6e\u56fe\u7247\u4ed3\u5e93\u5236\u4f5c\u7f29\u7565\u56fe\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528\u5185\u7f6e\u56fe\u7247\u4ed3\u5e93\u5236\u4f5c\u7f29\u7565\u56fe\uff1f WordPress \u4e0d\u4ec5\u662f\u535a\u5ba2, \u5f88\u591a\u65f6\u5019 WordPress \u8fd8\u88ab\u7528\u4f5c\u4e3a CMS (\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf). \u535a\u4e3b\u4eec\u559c\u6b22\u4e3a\u6bcf\u4e2a\u6587\u7ae0\u52a0\u4e0a\u7edf\u4e00\u5927\u5c0f\u7684\u7f29\u7565\u56fe, \u5c24\u5176\u662f\u4fe1\u606f\u7c7b\u5e73\u53f0. \u5176\u4e2d\u6bd4\u8f83\u5e38\u7528\u7684\u5904\u7406\u529e\u6cd5\u662f\u7528 custom field \u5411\u6587\u7ae0\u63d2\u5165\u56fe\u7247, \u901a\u8fc7\u4e0a\u4f20\u5927\u5c0f\u4e00\u81f4\u7684\u5c0f\u56fe\u6216\u8005\u4f7f\u7528 phpThumb \u7b49\u5de5\u5177\u751f\u6210\u7f29\u7565\u56fe.&nbsp; &nbsp;\u63a8\u8350\uff1a\u300a\u300b 2.7 \u5f00\u59cb, WordPress \u5927\u5e45\u63d0\u5347\u591a\u5a92\u4f53\u529f\u80fd, \u8d8a\u6765\u8d8a\u591a\u4eba\u4f7f\u7528 WP \u7684\u5185\u7f6e\u56fe\u7247\u4ed3\u5e93. \u5bf9\u8fd9\u4e9b\u7528\u6237\u6765\u8bf4, \u5236\u4f5c\u7f29\u7565\u56fe\u53d8\u5f97\u5e76\u4e0d\u90a3\u4e48\u56f0\u96be, \u5728\u4e0a\u4f20\u56fe\u7247\u7684\u65f6\u5019\u5c31\u4f1a\u9ed8\u8ba4\u751f\u6210 150&#215;150 \u89c4\u683c\u7684\u5c0f\u56fe (\u5982\u679c\u56fe\u7247\u9ad8\u5ea6\/\u5bbd\u5ea6\u4e0d\u8db3 150px, \u4f7f\u7528\u539f\u9ad8\u5ea6\/\u5bbd\u5ea6). \u90a3\u6211\u4eec\u53ef\u4ee5\u5145\u5206\u5229\u7528\u8fd9\u4e2a\u529f\u80fd, \u5728\u6587\u7ae0\u5217\u8868\u4e0a\u52a0\u4e0a\u8fd9\u4e2a\u56fe\u7247\u4f5c\u4e3a\u7f29\u7565\u56fe. \u8fd9\u6837\u5904\u7406\u5404\u6709\u5229\u5f0a, \u597d\u5904\u662f\u7b80\u5355, \u667a\u80fd (\u4e0d\u7528\u6bcf\u6b21\u8f93\u5165\u7f29\u7565\u56fe), \u574f\u5904\u662f\u6d88\u8017\u670d\u52a1\u5668\u6d41\u91cf.&nbsp; Okay, \u73b0\u5728\u8981\u505a\u7684\u5c31\u662f\u63d0\u53d6\u4e0a\u4f20\u751f\u6210\u7684\u5c0f\u56fe\u7247, \u5e76\u653e\u7f6e\u5728\u6587\u7ae0\u7684\u9002\u5f53\u4f4d\u7f6e. \u6211\u521b\u5efa\u4e86\u4e00\u4e2a\u6587\u4ef6 thumb.php, \u56fe\u7247\u83b7\u53d6\u548c\u8c03\u7528\u4e00\u8d77\u5904\u7406, \u6587\u4ef6\u5185\u5bb9\u5982\u4e0b.&nbsp; \u4ee3\u7801\u5982\u4e0b: &lt;?php $args = array( &#039;numberposts&#039; =&gt;&nbsp;1,&nbsp; &#8216;order&#8217;=&amp;gt;&nbsp;&#8216;ASC&#8217;,&nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-30925","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=30925"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30925\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}