{"id":4169,"date":"2011-11-30T13:00:32","date_gmt":"2011-11-30T05:00:32","guid":{"rendered":"http:\/\/www.lmyoaoa.com\/inn\/?p=4169"},"modified":"2011-11-30T14:05:11","modified_gmt":"2011-11-30T06:05:11","slug":"wp%e4%bc%98%e5%8c%96wordpress%e9%82%a3%e5%9d%91%e7%88%b9%e7%9a%84%e5%87%bd%e6%95%b0%e4%b8%8e%e9%82%a3%e5%9d%91%e7%88%b9%e7%9a%84%e6%95%88%e7%8e%87","status":"publish","type":"post","link":"http:\/\/www.lmyoaoa.com\/inn\/archives\/4169\/","title":{"rendered":"[WP\u4f18\u5316]wordpress\u90a3\u5751\u7239\u7684\u51fd\u6570\u4e0e\u90a3\u5751\u7239\u7684\u6548\u7387"},"content":{"rendered":"<p><a href=\"http:\/\/www.lmyoaoa.com\/inn\/wp-content\/uploads\/2009\/10\/16V9BANNER091022000.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1965\" title=\"16V9BANNER091022000\" src=\"http:\/\/www.lmyoaoa.com\/inn\/wp-content\/uploads\/2009\/10\/16V9BANNER091022000.jpg\" alt=\"\" width=\"512\" height=\"98\" \/> <\/a><\/p>\n<p>\u4e00\u76f4\u90fd\u611f\u89c9wp\u7684\u6548\u7387\u4e0d\u592a\u884c\uff0c\u4e00\u76f4\u6ca1\u53bb\u770b\u770b\u5230\u5e95wp\u90a3\u91cc\u6162\u4e86\u3002\u4eca\u5929\u6709\u70b9\u65f6\u95f4\u5c31\u62bd\u7a7a\u8ba9\u6211\u6765\u770b\u770bwp\u9996\u9875\u4ee5\u53ca\u6587\u7ae0\u9875\u9762\u5230\u5e95\u8fd0\u884c\u4e86\u54ea\u4e9bsql\u5427\u3002 <img src=\"http:\/\/www.lmyoaoa.com\/inn\/wp-includes\/images\/smilies\/2007-6-26_16-51-57.gif\" alt=\":arrow:\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>\n<p>\u4e00\u76f4\u90fd\u662f\u542c\u8bf4wp\u6bcf\u6b21\u6253\u5f00\u90fd\u4f1a\u6709\u5927\u91cf\u7684\u8bf7\u6c42\uff0c\u6628\u5929\u67e5\u4e86\u4e00\u4e0b\uff0c\u9996\u9875\u6709\u8fd120\u6761\u7684sql\u67e5\u8be2\uff08\u4e0d\u5305\u62ec\u6211\u7528\u4e86memcached\u7f13\u5b58\u7684\uff09\uff0c\u6587\u7ae0\u9875\u7684\u8bdd\u6709\u5dee\u4e0d\u591a25\u6761\u67e5\u8be2\uff0c\u628asql\u8f93\u51fa\u4e00\u4e0b\u770b\u50bb\u4e86\u3002\u8fd9\u5565\u554a\u5404\u79cd\u8054\u8868\u5404\u79cd\u8868\u8fbe\u5f0f\u3002 :s1liuxue<\/p>\n<p>\u8fd0\u884cwp\u7684<strong>get_links_list()<\/strong>\u51fd\u6570\uff0c\u76d1\u89c6\u4e00\u4e0bsql\u53ef\u4ee5\u770b\u5230:<\/p>\n<pre>SELECT *  , IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated  , UNIX_TIMESTAMP(link_updated) AS link_updated_f  FROM wp_links  INNER JOIN wp_term_relationships AS tr ON (wp_links.link_id = tr.object_id) INNER JOIN wp_term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id WHERE 1=1 AND link_visible = 'Y'  AND ( tt.term_id = 2 ) AND taxonomy = 'link_category'    ORDER BY link_name ASC\r\n<\/pre>\n<p>\u8fd9\u53e5\u4e1c\u897f\u3002\u5c31\u6211\u73b0\u5728\u8fd9\u79cd\u5c0f\u8868\u90fd\u9700\u89810.1\u79d2\u7684\u67e5\u8be2\u65f6\u95f4\uff0c\u8868\u5927\u4e86\u7684\u8bdd\uff0c\u4f1a\u5f88\u641e\u7b11\u7684\u3002\u6240\u4ee5\u5404\u4f4d\u7528wp\uff0c\u800c\u4e14\u6709\u4f7f\u7528<strong>get_links_list()<\/strong>\u8fd9\u4e2a\u51fd\u6570\u6765\u83b7\u53d6\u53cb\u94fe\u7684\u540c\u5b66\u8d76\u7d27\u6362\u5176\u4ed6\u65b9\u5f0f\u5427\u3002\u4e0d\u8981\u7528\u8fd9\u4e2a\u51fd\u6570\u4e86\u3002<\/p>\n<p>\u5047\u5982\u4f60\u7684\u53cb\u94fe\u5173\u7cfb\u4e0d\u590d\u6742\uff0c\u50cf\u6211\u4e00\u6837\u6ca1\u6709\u505a\u5206\u7c7b\u4ec0\u4e48\u7684\uff0c\u76f4\u63a5\u7528\u4e0b\u9762\u8fd9\u53e5\u5c31\u884c\u4e86\uff0c\u4e0d\u660e\u767dwp\u5b98\u65b9\u4e3a\u4ec0\u4e48\u4f1a\u5c06link_visible\u8fd9\u4e2a\u5b57\u6bb5\u91c7\u7528\u5b57\u7b26\u578b\u505a\u8bb0\u5f55\uff0c\u867d\u7136\u5efa\u4e86\u7d22\u5f15\u4f46mysql\u8dd1\u53bb\u626b\u5168\u8868\u4e86\u3002 <img src=\"http:\/\/www.lmyoaoa.com\/inn\/wp-includes\/images\/smilies\/286DBC387FE29C7DB09304D966EE1C7E.gif\" alt=\":s1gouxuelt\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>\n<pre>select * from wp_links where link_visible='Y' order by link_name asc<\/pre>\n<p>\u4e8e\u662f\u4ece\u67e5\u8be2\u5230\u663e\u793a\uff0c\u53ef\u4ee5\u5728\u9875\u9762\u4e0a\u641e\u8fd9\u4e48\u4e00\u6bb5\uff1a<\/p>\n<pre>\r\n#global $wpdb;\t\/\/\u8fd9\u5e94\u8be5\u5199\u4e0d\u5199\u65e0\u6240\u8c13\r\n$links_wpdb = $wpdb->get_results(\"select * from wp_links where link_visible='Y' order by link_name asc\");\r\n\r\nif( $links_wpdb ) {\r\n        foreach( $links_wpdb as $k=>$v ) {\r\n                $tmpstr .= '< li >< a title=\"'.$v->link_description.'\" href=\"'.$v->link_url.'\" target=\"'.$v->link_target.'\">'.$v->link_name.'< \/a >< \/ li >'; \/\/\u6ce8\u610f\u53bb\u6389\u4e00\u4e9b\u5730\u65b9\u7684\u7a7a\u683c\r\n        }\r\n        echo $tmpstr;\r\n}\r\n<\/pre>\n<p>\u5047\u5982\u4f60\u7684\u670d\u52a1\u5668\u5b89\u88c5\u4e86memcached\uff0c\u90a3\u4e48\u53ef\u4ee5\u8fd9\u6837\uff0c\u52a0\u4e86\u7f13\u5b58\u51cf\u5c11\u6570\u636e\u5e93\u538b\u529b :s1niuyao<br \/>\n<!--more--><\/p>\n<pre>\r\n#$mc = new Memcache;\r\n#$mc->connect('\u670d\u52a1\u5668ip', '\u7aef\u53e3\u53f7');\r\nif( $mc ) {\r\n        $tmpstr = $mc->get(\"mc_links\");\r\n}\r\nif( !$tmpstr ) {\r\n        #global $wpdb;\r\n        $links_wpdb = $wpdb->get_results(\"select * from wp_links where link_visible='Y' order by link_name asc\");\r\n\r\n        if( $links_wpdb ) {\r\n                foreach( $links_wpdb as $k=>$v ) {\r\n                        $tmpstr .= '< li>< a title=\"'.$v->link_description.'\" href=\"'.$v->link_url.'\" target=\"'.$v->link_target.'\">'.$v->link_name.'<\/ a><\/ li>';\r\n                }\r\n        }\r\n        $mc->set('mc_links', $tmpstr, MEMCACHE_COMPRESSED, 3600*24);\r\n}\r\necho $tmpstr;\r\n<\/pre>\n<p>\u5514&#8230;\u4ee5\u4e0a\u5c31\u662f\u505a\u4e8624\u5c0f\u65f6\u7f13\u5b58\u7684\u53cb\u60c5\u94fe\u63a5\u4e86\uff0c\u6709\u4e2a\u5f0a\u7aef\u5c31\u662f\uff0c\u4f60\u73b0\u5728\u6dfb\u52a0\u7684\u65b0\u7684\u53cb\u94fe\uff0c\u6709\u53ef\u80fd\u9700\u8981\u7b49\u5f8524\u5c0f\u65f6\u624d\u80fd\u5728\u9875\u9762\u4e0a\u770b\u5230\u3002\u4e0d\u52a8wp\u7a0b\u5e8f\uff0c\u4e0d\u5199hook\uff0c\u53ea\u80fd\u8ba9\u4ed6\u6709\u4e2a\u5ef6\u8fdf\u65f6\u95f4\u4e86\uff0c\u5047\u5982\u5e0c\u671b\u65f6\u95f4\u77ed\u70b9\uff0c\u628a\u4e0a\u9762\u76843600*24\u6539\u6210\u4f60\u60f3\u8981\u7684\u79d2\u6570\u5373\u53ef\u3002<\/p>\n<p>\u597d\u50cf\u5c31\u4e00\u6761\u8bed\u53e5\u5c31\u80fd\u5199\u7bc7\u535a\u5ba2\u4e86&#8230;\u90a3\u5c31\u8fd9\u6837\u5427\uff0c\u4e0d\u5199\u4e86 <img src=\"http:\/\/www.lmyoaoa.com\/inn\/wp-includes\/images\/smilies\/10F8B3B531E117913365118FB226D62F.gif\" alt=\":s1ruo\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>\n<p>PS\uff1a\u6709\u7a7a\u5f97\u628a\u8868\u60c5\u5904\u7406\u4e00\u4e0b\uff0c\u670d\u52a1\u5668\u94fe\u63a5\u6570\u4e5f\u597d\u591a..<\/p>\n<p>PS2\uff1a\u5c0f\u5199\u4e00\u6bb5\uff0c\u9ad8\u624b\u65e0\u89c6\u5373\u53ef\u3002<\/p>\n<p>PS3\uff1a\u5e1d\u90fd\u600e\u4e48\u8fd8\u4e0d\u7ed9\u6211\u4e0b\u96ea\u554a\uff01\uff01\uff01 <img src=\"http:\/\/www.lmyoaoa.com\/inn\/wp-includes\/images\/smilies\/DE2C79B8D58B93114712EA054D3ACE42.gif\" alt=\":s1dahong\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/>  <img src=\"http:\/\/www.lmyoaoa.com\/inn\/wp-includes\/images\/smilies\/DE2C79B8D58B93114712EA054D3ACE42.gif\" alt=\":s1dahong\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/>  <img src=\"http:\/\/www.lmyoaoa.com\/inn\/wp-includes\/images\/smilies\/DE2C79B8D58B93114712EA054D3ACE42.gif\" alt=\":s1dahong\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u76f4\u90fd\u611f\u89c9wp\u7684\u6548\u7387\u4e0d\u592a\u884c\uff0c\u4e00\u76f4\u6ca1\u53bb\u770b\u770b\u5230\u5e95wp\u90a3\u91cc\u6162\u4e86\u3002\u4eca\u5929\u6709\u70b9\u65f6\u95f4\u5c31\u62bd\u7a7a\u8ba9\u6211\u6765\u770b\u770bwp\u9996\u9875\u4ee5\u53ca\u6587\u7ae0\u9875\u9762\u5230\u5e95 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-4169","post","type-post","status-publish","format-standard","hentry","category-phpmysql"],"_links":{"self":[{"href":"http:\/\/www.lmyoaoa.com\/inn\/wp-json\/wp\/v2\/posts\/4169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.lmyoaoa.com\/inn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.lmyoaoa.com\/inn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.lmyoaoa.com\/inn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.lmyoaoa.com\/inn\/wp-json\/wp\/v2\/comments?post=4169"}],"version-history":[{"count":6,"href":"http:\/\/www.lmyoaoa.com\/inn\/wp-json\/wp\/v2\/posts\/4169\/revisions"}],"predecessor-version":[{"id":4176,"href":"http:\/\/www.lmyoaoa.com\/inn\/wp-json\/wp\/v2\/posts\/4169\/revisions\/4176"}],"wp:attachment":[{"href":"http:\/\/www.lmyoaoa.com\/inn\/wp-json\/wp\/v2\/media?parent=4169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.lmyoaoa.com\/inn\/wp-json\/wp\/v2\/categories?post=4169"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.lmyoaoa.com\/inn\/wp-json\/wp\/v2\/tags?post=4169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}