{"id":678,"date":"2013-01-08T08:15:46","date_gmt":"2013-01-08T00:15:46","guid":{"rendered":"https:\/\/sdeno.com\/?p=678"},"modified":"2013-01-08T08:17:13","modified_gmt":"2013-01-08T00:17:13","slug":"wordpress-%e6%97%a0%e6%8f%92%e4%bb%b6%e5%ae%9e%e7%8e%b0%e9%9d%a2%e5%8c%85%e5%b1%91%e4%bb%a3%e7%a0%81%e4%b8%80%e6%a0%b7%e6%95%88%e6%9e%9c","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=678","title":{"rendered":"wordpress \u65e0\u63d2\u4ef6\u5b9e\u73b0\u9762\u5305\u5c51\u4ee3\u7801\u4e00\u6837\u6548\u679c"},"content":{"rendered":"<p>wordpress \u4e0d\u7528\u63d2\u4ef6\u5b9e\u73b0\u9762\u5305\u5c51\u4ee3\u7801\u4e00\u6837\u6548\u679c\uff0c\u4e4b\u524d\u5c0f\u7f16\u7528\u7684\u662f\u63d2\u4ef6\u529f\u80fd\u8fd8\u633a\u5f3a\u5927\u4f46\u662f\u5927\u90e8\u5206\u529f\u80fd\u90fd\u7528\u4e0d\u4e0a\u89c9\u5f97\u6ca1\u6709\u5fc5\u8981\u5728\u8bf4\u5c0f\u7f16\u5e76\u4e0d\u559c\u6b22\u7528\u63d2\u4ef6\u5c3d\u91cf\u907f\u514d\u3002<\/p>\n<p>\u8fd9\u91cc\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u7eaf\u4ee3\u7801\u5b9e\u73b0\u6587\u7ae0\u5bfc\u822a\u8def\u5f84\u5206\u7c7b\u3002<\/p>\n<p>1\uff0c\u5728functions.php\u4ee3\u7801\u672b\u7aef\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>[code]function get_breadcrumbs()<br \/>\n{<\/p>\n<p>global $wp_query;<br \/>\nif ( !is_home().get_settings(&#8216;home&#8217;) ){<br \/>\n\/\/ Start the UL<br \/>\necho &#8216;&lt;ul&gt;&#8217;;<br \/>\n\/\/ Add the Home link<br \/>\necho &#8216;&lt;a href=&#8221;&#8216;. get_settings(&#8216;home&#8217;) .'&#8221;&gt;&#8217;. \u60a8\u76ee\u524d\u6240\u5728\u7684\u4f4d\u7f6e\uff1a\u9996\u9875 .'&lt;\/a&gt;&#8217;;<br \/>\nif ( is_category() )<br \/>\n{<br \/>\n$catTitle = single_cat_title( &#8220;&#8221;, false );<br \/>\n$cat = get_cat_ID( $catTitle );<br \/>\necho &#8221; &amp;raquo; &#8220;. get_category_parents( $cat, TRUE, &#8221; &amp;raquo; &#8221; ) ;<br \/>\n}<br \/>\nelseif ( is_archive() &amp;&amp; !is_category() )<br \/>\n{<br \/>\necho &#8220;&amp;raquo; Archives&#8221;;<br \/>\n}<br \/>\nelseif ( is_search() ) {<br \/>\necho &#8220;&amp;raquo; \u641c\u7d22\u7684\u7ed3\u679c&#8221;;<br \/>\n}<br \/>\nelseif ( is_404() )<br \/>\n{<br \/>\necho &#8220;&amp;raquo; 404 Not Found&#8221;;<br \/>\n}<br \/>\nelseif ( is_single() )<br \/>\n{<br \/>\n$category = get_the_category();<br \/>\n$category_id = get_cat_ID( $category[0]-&gt;cat_name );<br \/>\necho &#8216;&amp;raquo; &#8216;. get_category_parents( $category_id, TRUE, &#8221; &amp;raquo; &#8221; );<br \/>\necho the_title(&#8221;,&#8221;, FALSE);<br \/>\n}<br \/>\nelseif ( is_page() )<br \/>\n{<br \/>\n$post = $wp_query-&gt;get_queried_object();<br \/>\nif ( $post-&gt;post_parent == 0 ){<br \/>\necho &#8220;&lt;li&gt; &amp;raquo; &#8220;.the_title(&#8221;,&#8221;, FALSE).&#8221;&lt;\/li&gt;&#8221;;<br \/>\n} else {<br \/>\n$title = the_title(&#8221;,&#8221;, FALSE);<br \/>\n$ancestors = array_reverse( get_post_ancestors( $post-&gt;ID ) );<br \/>\narray_push($ancestors, $post-&gt;ID);<br \/>\nforeach ( $ancestors as $ancestor ){<br \/>\nif( $ancestor != end($ancestors) ){<br \/>\necho &#8216;&lt;li&gt; &amp;raquo; &lt;a href=&#8221;&#8216;. get_permalink($ancestor) .'&#8221;&gt;&#8217;. strip_tags( apply_filters( &#8216;single_post_title&#8217;, get_the_title( $ancestor ) ) ) .'&lt;\/a&gt;&lt;\/li&gt;&#8217;;<br \/>\n} else {<br \/>\necho &#8216;&lt;li&gt; &amp;raquo; &#8216;. strip_tags( apply_filters( &#8216;single_post_title&#8217;, get_the_title( $ancestor ) ) ) .'&lt;\/li&gt;&#8217;;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n\/\/ End the UL<br \/>\necho &#8220;&lt;\/ul&gt;&#8221;;<br \/>\n}<br \/>\n}[\/code]<\/p>\n<p>2\uff0c\u5728\u9700\u8981\u7684\u5730\u65b9\u8c03\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>[code]&lt;div class=&#8221;breadcrumbs&#8221;&gt;<\/p>\n<p>&lt;?php<br \/>\nif (function_exists(&#8216;get_breadcrumbs&#8217;)){<br \/>\nget_breadcrumbs();<br \/>\n}<br \/>\n?&gt;<br \/>\n&lt;\/div&gt;[\/code]<\/p>\n<p>3\uff0cCSS\u6837\u5f0f\u4ee3\u7801\uff0c\u8fd9\u4e2a\u53ef\u4ee5\u81ea\u884c\u4fee\u6539\u8fd9\u91cc\u6211\u63d0\u4f9b\u81ea\u5df1\u5199\u7684\u6837\u5f0f\uff1a<\/p>\n<p>[code].breadcrumbs ul{<br \/>\nmargin-left:12px;<br \/>\nmargin-top:40px;<br \/>\nline-height:20px;<br \/>\nfont-weight:bold;<br \/>\nword-wrap:break-word;<\/p>\n<p>}<br \/>\n.breadcrumbs ul a{<br \/>\ntext-decoration:none;<br \/>\ncolor:#000;<br \/>\n}<br \/>\n.breadcrumbs ul a:hover{<br \/>\ntext-decoration:underline;<br \/>\n}[\/code]<\/p>\n<p>\u8fd9\u91cc\u8bf4\u660e\u4e0bfunctions.php\u6240\u6dfb\u52a0\u7684\u4ee3\u7801\uff0c\u5f53\u8bbf\u95ee\u5728\u9996\u9875\u7684\u65f6\u5019\u662f\u9ed8\u8ba4\u663e\u793a\u201c\u60a8\u76ee\u524d\u6240\u5728\u7684\u4f4d\u7f6e\uff1a\u9996\u9875\u201d\u7684\uff0c\u5982\u679c\u4e0d\u5e0c\u671b\u8bbf\u95ee\u9996\u9875\u663e\u793a\u800c\u662f\u8fdb\u5165\u4e8c\u7ea7\u76ee\u5f55\u65f6\u624d\u663e\u793a\u5f53\u524d\u4f4d\u7f6e\uff0c\u4f60\u53ef\u4ee5\u628a\u4ee5\u4e0b\u4ee3\u7801\u3002<\/p>\n<p>\u5c06\u4ee3\u7801\uff1a<\/p>\n<p>[code]if ( !is_home().get_settings(&#8216;home&#8217;) )[\/code]<\/p>\n<p>\u4fee\u6539\u4e3a\uff1a<\/p>\n<p>[code]if ( !is_home())[\/code]<\/p>\n<p>\u4e5f\u5c31\u662f\u5c06\u4ee3\u7801get_settings(&#8216;home&#8217;)\u5220\u9664\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>wordpress \u4e0d\u7528\u63d2\u4ef6\u5b9e\u73b0\u9762\u5305\u5c51\u4ee3\u7801\u4e00\u6837\u6548\u679c\uff0c\u4e4b\u524d\u5c0f\u7f16\u7528\u7684\u662f\u63d2\u4ef6\u529f\u80fd\u8fd8\u633a\u5f3a\u5927\u4f46\u662f\u5927\u90e8\u5206\u529f\u80fd\u90fd\u7528\u4e0d\u4e0a\u89c9\u5f97\u6ca1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,11],"tags":[],"class_list":["post-678","post","type-post","status-publish","format-standard","hentry","category-wordpress","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=678"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}