{"id":653931,"date":"2025-10-01T09:35:43","date_gmt":"2025-10-01T01:35:43","guid":{"rendered":"http:\/\/puo.cn\/?p=653931"},"modified":"2025-10-01T09:35:43","modified_gmt":"2025-10-01T01:35:43","slug":"wordpress%e6%b7%bb%e5%8a%a0%e5%89%af%e6%a0%87%e9%a2%98%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"http:\/\/puo.cn\/?p=653931","title":{"rendered":"wordpress\u6dfb\u52a0\u526f\u6807\u9898\u4ee3\u7801"},"content":{"rendered":"<p>\u5728 WordPress \u91cc\u201c\u526f\u6807\u9898\u201d\u5e76\u4e0d\u662f\u5b98\u65b9\u672f\u8bed\uff0c\u901a\u5e38\u5927\u5bb6\u60f3\u8981\u7684\u662f\u4e0b\u9762\u4e24\u79cd\u60c5\u51b5\u4e4b\u4e00\uff1a<br \/>\nA. \u7ed9\u6587\u7ae0\/\u9875\u9762\u52a0\u4e00\u4e2a\u526f\u6807\u9898\uff08subtitle\uff09\uff0c\u8ba9\u5b83\u663e\u793a\u5728\u6b63\u5f0f\u6807\u9898\u4e0b\u65b9\uff1b<br \/>\nB. \u7ed9\u7ad9\u70b9\u672c\u8eab\u52a0\u4e00\u4e2a\u526f\u6807\u9898\uff08tagline\uff09\uff0c\u548c\u7ad9\u70b9\u6807\u9898\u5e76\u5217\u6216\u653e\u5728\u663e\u773c\u4f4d\u7f6e\u3002<\/p>\n<p>\u4e0b\u9762\u5206\u522b\u7ed9\u51fa\u201c\u7eaf\u4ee3\u7801\u3001\u4e0d\u88c5\u63d2\u4ef6\u201d\u7684\u6700\u7b80\u505a\u6cd5\uff0c\u76f4\u63a5\u6254\u8fdb\u4e3b\u9898\uff08\u6216\u5b50\u4e3b\u9898\uff09\u7684 functions.php \u5c31\u80fd\u751f\u6548\u3002<br \/>\n\u6240\u6709\u4ee3\u7801\u5747\u53bb\u6389 &lt;?php \u5f00\u5934\uff0c\u5982\u679c\u4f60\u7684 functions.php \u91cc\u5df2\u7ecf\u6709 &lt;?php \u5c31\u63a5\u5728\u540e\u9762\u5373\u53ef\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u4e00\u3001\u7ed9\u201c\u6587\u7ae0\/\u9875\u9762\u201d\u52a0\u526f\u6807\u9898\uff08Subtitle\uff09<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n1. \u5148\u5728\u6570\u636e\u5e93\u91cc\u628a\u526f\u6807\u9898\u5b58\u4e0b\u6765<br \/>\n\u7528 WordPress \u81ea\u5e26\u7684\u201c\u81ea\u5b9a\u4e49\u5b57\u6bb5\u201d\u673a\u5236\uff0c\u5b57\u6bb5\u540d\u56fa\u5b9a\u4e3a subtitle \uff0c\u540e\u53f0\u6bcf\u7bc7\u6587\u7ae0\u586b\u4e00\u6b21\u5373\u53ef\u3002<\/p>\n<p>2. \u8ba9\u540e\u53f0\u8f93\u5165\u6846\u66f4\u4eba\u6027\u5316\uff08\u53ef\u9009\uff09<br \/>\n\u628a\u4e0b\u9762\u4ee3\u7801\u6254\u8fdb functions.php \uff0c\u4f1a\u5728\u6587\u7ae0\/\u9875\u9762\u7f16\u8f91\u754c\u9762\u7684\u6807\u9898\u4e0b\u65b9\u591a\u4e00\u4e2a\u201c\u526f\u6807\u9898\u201d\u8f93\u5165\u6846\uff0c\u4fdd\u5b58\u65f6\u81ea\u52a8\u5199\u8fdb\u81ea\u5b9a\u4e49\u5b57\u6bb5 subtitle \u3002<\/p>\n<p>&#8220;`<br \/>\n\/* \u540e\u53f0\u526f\u6807\u9898\u8f93\u5165\u6846 *\/<br \/>\nadd_action(&#8216;edit_form_after_title&#8217;, &#8216;my_subtitle_input&#8217;);<br \/>\nfunction my_subtitle_input($post){<br \/>\n$value = get_post_meta($post-&gt;ID, &#8216;subtitle&#8217;, true);<br \/>\nwp_nonce_field(&#8216;subtitle_nonce&#8217;, &#8216;subtitle_nonce&#8217;);<br \/>\necho &#8216;&lt;h4 style=&#8221;margin-bottom:4px;&#8221;&gt;\u526f\u6807\u9898&lt;\/h4&gt;&#8217;;<br \/>\necho &#8216;&lt;input type=&#8221;text&#8221; name=&#8221;subtitle&#8221; style=&#8221;width:100%;font-size:1.2em;&#8221; value=&#8221;&#8216;.esc_attr($value).'&#8221;&gt;&#8217;;<br \/>\n}<\/p>\n<p>\/* \u4fdd\u5b58\u65f6\u5199\u5e93 *\/<br \/>\nadd_action(&#8216;save_post&#8217;, &#8216;my_save_subtitle&#8217;);<br \/>\nfunction my_save_subtitle($post_id){<br \/>\nif (defined(&#8216;DOING_AUTOSAVE&#8217;) &amp;&amp; DOING_AUTOSAVE) return;<br \/>\nif (!isset($_POST[&#8216;subtitle_nonce&#8217;]) || !wp_verify_nonce($_POST[&#8216;subtitle_nonce&#8217;], &#8216;subtitle_nonce&#8217;)) return;<br \/>\nif (current_user_can(&#8216;edit_post&#8217;, $post_id)){<br \/>\nupdate_post_meta($post_id, &#8216;subtitle&#8217;, sanitize_text_field($_POST[&#8216;subtitle&#8217;]));<br \/>\n}<br \/>\n}<br \/>\n&#8220;`<\/p>\n<p>3. \u5728\u524d\u7aef\u628a\u526f\u6807\u9898\u5410\u51fa\u6765<br \/>\n\u6253\u5f00\u4e3b\u9898\u91cc\u8d1f\u8d23\u8f93\u51fa\u6807\u9898\u7684\u6a21\u677f\u6587\u4ef6\uff08single.php \u6216 content-single.php \u4e4b\u7c7b\uff09\uff0c\u5728 the_title() \u4e0b\u65b9\u52a0\u4e00\u884c\uff1a<\/p>\n<p>&#8220;`<br \/>\nif($sub = get_post_meta(get_the_ID(), &#8216;subtitle&#8217;, true))<br \/>\necho &#8216;&lt;h2 class=&#8221;subtitle&#8221;&gt;&#8217;.esc_html($sub).'&lt;\/h2&gt;&#8217;;<br \/>\n&#8220;`<\/p>\n<p>\u60f3\u7528 CSS \u8c03\u5b57\u53f7\u3001\u989c\u8272\uff0c\u7ed9 .subtitle \u5199\u6837\u5f0f\u5373\u53ef\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u4e8c\u3001\u7ed9\u201c\u6574\u4e2a\u7ad9\u70b9\u201d\u52a0\u526f\u6807\u9898\uff08Tagline\uff09<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nWordPress \u540e\u53f0\u201c\u8bbe\u7f6e\u2192\u5e38\u89c4\u201d\u91cc\u672c\u6765\u5c31\u6709\u201c\u526f\u6807\u9898\uff08Tagline\uff09\u201d\u5b57\u6bb5\uff0c\u53ea\u662f\u5f88\u591a\u4e3b\u9898\u6ca1\u628a\u5b83\u6446\u51fa\u6765\u3002<br \/>\n\u4e0b\u9762\u4e24\u884c\u4ee3\u7801\u76f4\u63a5\u628a\u5b83\u663e\u793a\u5728\u7ad9\u70b9\u6807\u9898\u540e\u9762\uff0c\u6254\u8fdb\u4e3b\u9898\u9002\u5f53\u4f4d\u7f6e\uff08\u5982 header.php \u91cc &lt;h1&gt; \u4e0b\u65b9\uff09\uff1a<\/p>\n<p>&#8220;`<br \/>\n&lt;h1 class=&#8221;site-title&#8221;&gt;&lt;?php bloginfo(&#8216;name&#8217;); ?&gt;&lt;\/h1&gt;<br \/>\n&lt;?php if(get_bloginfo(&#8216;description&#8217;,&#8217;display&#8217;)): ?&gt;<br \/>\n&lt;p class=&#8221;site-tagline&#8221;&gt;&lt;?php bloginfo(&#8216;description&#8217;); ?&gt;&lt;\/p&gt;<br \/>\n&lt;?php endif; ?&gt;<br \/>\n&#8220;`<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u4e09\u3001\u603b\u7ed3<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n1. \u6587\u7ae0\u7ea7\u526f\u6807\u9898\uff1a\u7528\u81ea\u5b9a\u4e49\u5b57\u6bb5 subtitle \u5b58\uff0c\u6a21\u677f\u91cc get_post_meta \u8bfb\u3002<br \/>\n2. \u7ad9\u70b9\u7ea7\u526f\u6807\u9898\uff1a\u7528\u7cfb\u7edf\u81ea\u5e26\u7684 bloginfo(&#8216;description&#8217;) \u8bfb\u3002<br \/>\n\u5168\u7a0b\u65e0\u9700\u63d2\u4ef6\uff0c\u4ee3\u7801\u91cf\u4e0d\u5230 30 \u884c\uff0c\u5347\u7ea7 WordPress \u4e5f\u4e0d\u4f1a\u4e22\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 WordPress \u91cc\u201c\u526f\u6807\u9898\u201d\u5e76\u4e0d\u662f\u5b98\u65b9\u672f\u8bed\uff0c\u901a\u5e38\u5927\u5bb6\u60f3\u8981\u7684\u662f\u4e0b\u9762\u4e24\u79cd\u60c5\u51b5\u4e4b\u4e00\uff1a A. \u7ed9\u6587\u7ae0\/\u9875\u9762\u52a0\u4e00\u4e2a\u526f\u6807\u9898\uff08subtitle\uff09\uff0c\u8ba9\u5b83\u663e\u793a\u5728\u6b63\u5f0f\u6807\u9898\u4e0b\u65b9\uff1b B. \u7ed9\u7ad9\u70b9\u672c\u8eab\u52a0\u4e00\u4e2a\u526f\u6807\u9898\uff08tagline\uff09\uff0c\u548c\u7ad9\u70b9\u6807\u9898\u5e76\u5217\u6216\u653e\u5728\u663e\u773c\u4f4d&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[136],"tags":[404],"topic":[342],"class_list":["post-653931","post","type-post","status-publish","format-standard","hentry","category-136","tag-wordpress","topic-wordpress"],"_links":{"self":[{"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts\/653931","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=653931"}],"version-history":[{"count":1,"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts\/653931\/revisions"}],"predecessor-version":[{"id":653932,"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts\/653931\/revisions\/653932"}],"wp:attachment":[{"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=653931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=653931"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=653931"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftopic&post=653931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}