{"id":8,"date":"2009-01-24T14:57:27","date_gmt":"2009-01-24T06:57:27","guid":{"rendered":"http:\/\/www.magki.com\/blog\/?p=8"},"modified":"2009-01-24T14:59:06","modified_gmt":"2009-01-24T06:59:06","slug":"add-aside-for-wordpress","status":"publish","type":"post","link":"http:\/\/www.ijony.com\/blog\/2009\/01\/add-aside-for-wordpress.html","title":{"rendered":"\u7ed9 WordPress \u6dfb\u52a0 Aside \u529f\u80fd"},"content":{"rendered":"<p>\u5f88\u65e9\u7684\u65f6\u5019\uff0c\u5e38\u5e38\u4e3a\u4e86\u8981\u53d1\u5e03\u4e00\u4e9b\u7b80\u5355\u7684\u6d88\u606f\u800c\u4e0d\u5f97\u4e0d\u6324\u534a\u5929\u7259\u818f\u76ae\uff0c\u4ee5\u514d\u4e00\u7bc7\u65e5\u5fd7\u91cc\u5c31\u4e00\u4e24\u53e5\u8bdd\u800c\u663e\u5f97\u201c\u5f88\u6389\u9762\u5b50\u201d\u3002\u540e\u6765\u996d\u5426\u7b49\u201c\u5fae\u578b\u535a\u5ba2\u201d\u7684\u6d41\u884c\u7ed9\u4e86 \u81ea\u5df1\u4ee5\u542f\u8fea\uff0c\u6709\u540c\u6837\u60f3\u6cd5\u7684\u4eba\u4e5f\u6709\u4e0d\u5c11\uff0c\u751a\u81f3\u6709\u4e9b\u4eba\u5df2\u7ecf\u5c06\u8fd9\u7c7b\u201c\u5fae\u578b\u535a\u5ba2\u201d\u6574\u5408\u8fdb\u539f\u6709\u535a\u5ba2\u4e2d\u4e86\u3002\u4ee5\u524d\u81ea\u5df1\u4e5f\u7a0d\u7a0d\u7814\u7a76\u4e86\u4e0b\uff0c\u627e\u5230\u4e86\u6a21\u62df\u201c\u5fae\u578b\u535a \u5ba2\u201d\u5e76\u6574\u5408\u8fdb\u6765\u7684\u53ef\u884c\u6027\u65b9\u6848\uff0c\u5728\u8fd9\u91cc\u5171\u4eab\u4e00\u4e0b\u3002<\/p>\n<p>\u5206\u51e0\u6b65\u4fee\u6539\uff0c\u9996\u5148\u5efa\u7acb\u4e00\u4e2a\u65b0\u7684\u5206\u7c7b\uff0c\u8bb0\u4f4f\u5176 ID\uff0c\u4e3a\u4e86\u540e\u6587\u53d9\u8ff0\u65b9\u4fbf\uff0c\u8fd9\u91cc\u5047\u8bbe ID \u4e3a 1\uff0c\u63a5\u4e0b\u6765\u7684\u4fee\u6539\u5185\u5bb9\u662f\u6253\u5f00\u4e3b\u9898\u4e2d\u7684 index.php \u6587\u4ef6\uff0c\u627e\u5230\u7c7b\u4f3c <span style=\"color: #ff0000;\">&lt;?php while (have_posts()) : the_post(); ?&gt;<\/span> \u7684\u4ee3\u7801\uff0c\u4ece\u4e0b\u4e00\u884c\u63d2\u5165<\/p>\n<blockquote><p>&lt;?php if ( the_category_ID(false) == <span style=\"color: #ff0000;\">1<\/span> ){ ?&gt;<br \/>\n&lt;div class=&#8221;aside&#8221;&gt;&lt;p&gt;&lt;?php echo get_the_content(); ?&gt; &lt;?php comments_popup_link(&#8216;(0)&#8217;, &#8216;(1)&#8217;, &#8216;(%)&#8217;); ?&gt; &lt;a href=&#8221;&lt;?php the_permalink() ?&gt;&#8221; rel=&#8221;bookmark&#8221;&gt;#&lt;\/a&gt; &lt;?php edit_post_link(&#8216;e&#8217;, &#8221;, &#8221;); ?&gt;&lt;\/p&gt;&lt;\/div&gt;<br \/>\n&lt;?php }else{ ?&gt;<\/p><\/blockquote>\n<p>\u5e76\u627e\u5230 <span style=\"color: #ff0000;\">endwhile;<\/span> \u4fee\u6539\u6210 <span style=\"color: #ff0000;\">} endwhile;<\/span> \u3002\u7ecf\u8fc7\u8fd9\u6837\u4fee\u6539\uff0c\u4ee5\u540e\u5f80 ID \u4e3a 1 \u7684\u5206\u7c7b\u91cc\u5199\u7684\u65e5\u5fd7\u5728\u9996\u9875\u90fd\u5c06\u5355\u72ec\u7528 &lt;div class=&#8221;aside&#8221;&gt;&lt;\/div&gt; \u5305\u542b\u901a\u8fc7 CSS \u8c03\u8282\u533a\u5206\u4e0b\u5c31\u53ef\u4ee5\u5f97\u5230\u6548\u679c\u4e86\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u63a5\u4e0b\u6765\u7684\u4fee\u6539\u53ef\u4ee5\u89c6\u81ea\u5df1\u7684\u8981\u6c42\u4fee\u6539\uff1a<\/p>\n<p>\u5982\u679c\u8981\u5355\u7bc7\u65e5\u5fd7\u9875\u4e5f\u989d\u5916\u5904\u7406\uff0c\u53ef\u4ee5\u4eff\u7167 index.php \u7684\u4fee\u6539\u65b9\u6cd5\u4f5c\u4fee\u6539 single.php\u3002\u5982\u679c\u9700\u8981\u4ece\u5206\u7c7b\u5217\u8868\u4e2d\u6392\u9664\u8fd9\u4e2a\u4e13\u7528\u5206\u7c7b\u5219\u53ef\u4ee5\u5728\u5206\u7c7b\u5217\u8868\u8c03\u7528\u51fd\u6570 wp_list_cats() \u4e2d\u52a0\u5165\u53c2\u6570 <span style=\"color: #ff0000;\">exclude=1<\/span>\u3002\u5982\u679c\u9700\u8981\u4ece\u6700\u65b0\u65e5\u5fd7\u5217\u8868\u4e2d\u53bb\u9664\u5219\u9700\u8981\u5728\u4e3b\u9898\u7684 functions.php \uff08\u5982\u679c\u6ca1\u6709\u5219\u5efa\u7acb\uff09\u6587\u4ef6\u4e2d\u7684 <span style=\"color: #ff0000;\">&lt;?php<\/span> \u4e4b\u4e0b\u63d2\u5165\uff1a<\/p>\n<blockquote><p>function Archives_Join($r){<br \/>\nglobal $wpdb;<\/p>\n<p>$r .= &#8220;LEFT JOIN $wpdb-&gt;term_relationships ON $wpdb-&gt;posts.ID = $wpdb-&gt;term_relationships.object_id LEFT JOIN $wpdb-&gt;term_taxonomy ON $wpdb-&gt;term_relationships.term_taxonomy_id = $wpdb-&gt;term_taxonomy.term_taxonomy_id LEFT OUTER JOIN $wpdb-&gt;terms ON $wpdb-&gt;term_taxonomy.term_id = $wpdb-&gt;terms.term_id&#8221;;<\/p>\n<p>return $r;<br \/>\n}<\/p>\n<p>function Archives_Where($r){<br \/>\nglobal $wpdb;<\/p>\n<p>$r .= &#8221; AND $wpdb-&gt;terms.term_id != <span style=\"color: #ff0000;\">1<\/span> AND $wpdb-&gt;term_taxonomy.taxonomy = &#8216;category'&#8221;;<\/p>\n<p>return $r;<br \/>\n}<\/p>\n<p>add_filter(&#8216;getarchives_join&#8217;, &#8216;Archives_Join&#8217;);<br \/>\nadd_filter(&#8216;getarchives_where&#8217;, &#8216;Archives_Where&#8217;);<\/p><\/blockquote>\n<p>\u6ce8\u610f\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u00a0 <span style=\"color: #ff0000;\">the_category_ID(false) == 1<\/span> \u4ee5\u53ca\u00a0<span style=\"color: #ff0000;\">$wpdb-&gt;terms.term_id != 1<\/span> \u91cc\u7684 <span style=\"color: #ff0000;\">1<\/span> \u9700\u8981\u4fee\u6539\u6210\u4e4b\u524d\u4f60\u5efa\u7acb\u7684\u5206\u7c7b ID\u3002OK\u4e86\uff0c\u5927\u529f\u544a\u6210\u3002\u4ee5\u540e\u6709\u65f6\u95f4\u518d\u7814\u7a76\u72ec\u7acb\u6570\u636e\u8868\u7684 Aside \u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f88\u65e9\u7684\u65f6\u5019\uff0c\u5e38\u5e38\u4e3a\u4e86\u8981\u53d1\u5e03\u4e00\u4e9b\u7b80\u5355\u7684\u6d88\u606f\u800c\u4e0d\u5f97\u4e0d\u6324\u534a\u5929\u7259\u818f\u76ae\uff0c\u4ee5\u514d\u4e00\u7bc7\u65e5\u5fd7\u91cc\u5c31\u4e00\u4e24\u53e5\u8bdd\u800c\u663e\u5f97\u201c\u5f88\u6389\u9762\u5b50\u201d\u3002\u540e\u6765 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/posts\/8"}],"collection":[{"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":0,"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/posts\/8\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/media?parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/categories?post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ijony.com\/blog\/wp-json\/wp\/v2\/tags?post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}