{"id":259,"date":"2024-09-24T22:51:54","date_gmt":"2024-09-24T14:51:54","guid":{"rendered":"http:\/\/www.woniuseo.com\/wordpress\/?p=259"},"modified":"2024-09-24T22:51:54","modified_gmt":"2024-09-24T14:51:54","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e5%88%9b%e5%bb%ba%e8%87%aa%e5%ae%9a%e4%b9%89%e9%a6%96%e9%a1%b5%e6%a8%a1%e6%9d%bf","status":"publish","type":"post","link":"http:\/\/www.woniuseo.com\/wordpress\/jiaocheng\/259.html","title":{"rendered":"\u5982\u4f55\u5728 WordPress \u4e2d\u521b\u5efa\u81ea\u5b9a\u4e49\u9996\u9875\u6a21\u677f"},"content":{"rendered":"
\u5728WordPress\u4e2d\u521b\u5efa\u81ea\u5b9a\u4e49\u9996\u9875\u6a21\u677f\uff0c\u662f\u63d0\u5347\u7f51\u7ad9\u4e2a\u6027\u5316\u4e0e\u7528\u6237\u4f53\u9a8c\u7684\u91cd\u8981\u6b65\u9aa4\u3002WordPress\u4ee5\u5176\u5f3a\u5927\u7684\u7075\u6d3b\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0c\u5141\u8bb8\u7528\u6237\u8f7b\u677e\u5b9a\u5236\u7f51\u7ad9\u7684\u6bcf\u4e00\u4e2a\u7ec6\u8282\uff0c\u5305\u62ec\u9996\u9875\u7684\u5e03\u5c40\u3001\u6837\u5f0f\u548c\u529f\u80fd\u3002\u4e0b\u9762\uff0c\u6211\u4eec\u5c06\u4e00\u6b65\u6b65\u6307\u5bfc\u4f60\u5982\u4f55\u5728WordPress\u4e2d\u521b\u5efa\u5e76\u5e94\u7528\u4e00\u4e2a\u81ea\u5b9a\u4e49\u9996\u9875\u6a21\u677f\u3002<\/p>\n
\u4e00\u3001\u4e86\u89e3WordPress\u6a21\u677f\u7ed3\u6784<\/p>\n
\u5728\u6df1\u5165\u521b\u5efa\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u4e86\u89e3WordPress\u7684\u6a21\u677f\u7cfb\u7edf\u3002WordPress\u4f7f\u7528\u4e3b\u9898\uff08Themes\uff09\u6765\u63a7\u5236\u7f51\u7ad9\u7684\u5916\u89c2\u548c\u611f\u89c9\uff0c\u800c\u4e3b\u9898\u7531\u591a\u4e2a\u6587\u4ef6\u7ec4\u6210\uff0c\u5176\u4e2d\u6700\u91cd\u8981\u7684\u662f`index.php`\uff0c\u5b83\u662f\u9ed8\u8ba4\u7684\u9996\u9875\u6a21\u677f\u3002\u4f46\u4e3a\u4e86\u521b\u5efa\u81ea\u5b9a\u4e49\u9996\u9875\uff0c\u6211\u4eec\u901a\u5e38\u4f1a\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a`front-page.php`\u7684\u65b0\u6587\u4ef6\uff0c\u6216\u8005\u901a\u8fc7\u51fd\u6570`is_front_page()`\u5728\u73b0\u6709\u6a21\u677f\u6587\u4ef6\u4e2d\u6dfb\u52a0\u6761\u4ef6\u903b\u8f91\u3002<\/p>\n
\u4e8c\u3001\u521b\u5efa`front-page.php`\u6587\u4ef6<\/p>\n
1. \u5b9a\u4f4d\u4e3b\u9898\u76ee\u5f55\uff1a\u9996\u5148\uff0c\u901a\u8fc7FTP\u5ba2\u6237\u7aef\u6216WordPress\u7684\u6587\u4ef6\u7ba1\u7406\u5668\u8bbf\u95ee\u4f60\u7684\u7f51\u7ad9\u670d\u52a1\u5668\uff0c\u627e\u5230\u4f60\u7684WordPress\u4e3b\u9898\u6587\u4ef6\u5939\u3002
\n2. \u521b\u5efa\u65b0\u6587\u4ef6\uff1a\u5728\u4e3b\u9898\u6587\u4ef6\u5939\u5185\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a`front-page.php`\u7684\u65b0\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u5c06\u4f5c\u4e3a\u4f60\u7684\u81ea\u5b9a\u4e49\u9996\u9875\u6a21\u677f\u3002
\n3. \u7f16\u5199\u6a21\u677f\u4ee3\u7801\uff1a\u4f7f\u7528HTML\u3001PHP\u548cWordPress\u6a21\u677f\u6807\u7b7e\u6765\u7f16\u5199\u4f60\u7684\u9996\u9875\u5185\u5bb9\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528`get_header()`\u6765\u5305\u542b\u5934\u90e8\u6587\u4ef6\uff0c`wp_loop()`\uff08\u6216\u81ea\u5b9a\u4e49\u67e5\u8be2\uff09\u6765\u5c55\u793a\u5185\u5bb9\uff0c\u4ee5\u53ca`get_footer()`\u6765\u5305\u542b\u5e95\u90e8\u6587\u4ef6\u3002<\/p>\n
\u4e09\u3001\u81ea\u5b9a\u4e49\u5185\u5bb9<\/p>\n
\u81ea\u5b9a\u4e49\u9996\u9875\u6a21\u677f\u7684\u6838\u5fc3\u5728\u4e8e\u5185\u5bb9\u7684\u5c55\u793a\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u6c42\uff0c\u8bbe\u8ba1\u72ec\u7279\u7684\u5e03\u5c40\u548c\u6837\u5f0f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n
“`php
\n<?php
\n\/\/ \u5f15\u5165\u5934\u90e8\u6587\u4ef6
\nget_header();
\n?><\/p>\n
<div id=”primary” class=”content-area”>
\n<main id=”main” class=”site-main”>
\n<section class=”home-section”>
\n<!– \u81ea\u5b9a\u4e49\u5185\u5bb9\u5f00\u59cb –>
\n<h1>\u6b22\u8fce\u6765\u5230\u6211\u7684\u7f51\u7ad9<\/h1>
\n<p>\u8fd9\u91cc\u662f\u4e00\u4e9b\u5173\u4e8e\u6211\u7684\u4ecb\u7ecd\uff0c\u4ee5\u53ca\u6211\u7f51\u7ad9\u7684\u4e3b\u8981\u5185\u5bb9\u6982\u89c8\u3002<\/p><\/p>\n
<!– \u5c55\u793a\u7279\u8272\u6587\u7ae0\u6216\u5185\u5bb9\u5757 –>
\n<?php
\n$args = array(
\n‘posts_per_page’ => 3, \/\/ \u663e\u793a3\u7bc7\u6587\u7ae0
\n‘category_name’ => ‘featured’ \/\/ \u5047\u8bbe\u6709\u4e00\u4e2a\u540d\u4e3a’featured’\u7684\u5206\u7c7b
\n);
\n$query = new WP_Query($args);
\nif ($query->have_posts()) :
\nwhile ($query->have_posts()) : $query->the_post();
\n?>
\n<article>
\n<h2><?php the_title(); ?><\/h2>
\n<p><?php the_excerpt(); ?><\/p>
\n<a href=”<?php the_permalink(); ?>”>\u9605\u8bfb\u5168\u6587<\/a>
\n<\/article>
\n<?php
\nendwhile;
\nwp_reset_postdata();
\nendif;
\n?>
\n<!– \u81ea\u5b9a\u4e49\u5185\u5bb9\u7ed3\u675f –>
\n<\/section>
\n<\/main>
\n<\/div><\/p>\n
<?php
\n\/\/ \u5f15\u5165\u5e95\u90e8\u6587\u4ef6
\nget_footer();
\n?>
\n“`<\/p>\n
\u56db\u3001\u8bbe\u7f6e\u9996\u9875\u6a21\u677f<\/p>\n
\u521b\u5efa\u5b8c`front-page.php`\u540e\uff0c\u4f60\u8fd8\u9700\u8981\u5728WordPress\u540e\u53f0\u8bbe\u7f6e\u5b83\u4f5c\u4e3a\u9996\u9875\u6a21\u677f\u3002<\/p>\n
1. \u767b\u5f55WordPress\u7ba1\u7406\u540e\u53f0\u3002
\n2. \u524d\u5f80\u201c\u8bbe\u7f6e\u201d > \u201c\u9605\u8bfb\u201d\u3002
\n3. \u5728\u201c\u60a8\u7684\u9996\u9875\u663e\u793a\u201d\u9009\u9879\u4e2d\uff0c\u9009\u62e9\u201c\u4e00\u4e2a\u9759\u6001\u9875\u9762\u201d\uff0c\u7136\u540e\u5728\u201c\u9996\u9875\u201d\u4e0b\u62c9\u83dc\u5355\u4e2d\u9009\u62e9\u4f60\u7684\u81ea\u5b9a\u4e49\u6a21\u677f\uff08\u867d\u7136\u76f4\u63a5\u521b\u5efa`front-page.php`\u540e\uff0cWordPress\u4f1a\u81ea\u52a8\u8bc6\u522b\u5b83\u4f5c\u4e3a\u9996\u9875\u6a21\u677f\uff0c\u4f46\u8fd9\u91cc\u786e\u8ba4\u4e00\u4e0b\u662f\u4e2a\u597d\u4e60\u60ef\uff09\u3002
\n4. \u70b9\u51fb\u201c\u4fdd\u5b58\u66f4\u6539\u201d\u3002<\/p>\n
\u4e94\u3001\u6d4b\u8bd5\u548c\u8c03\u6574<\/p>\n
\u5b8c\u6210\u4ee5\u4e0a\u6b65\u9aa4\u540e\uff0c\u8bbf\u95ee\u4f60\u7684\u7f51\u7ad9\u9996\u9875\uff0c\u67e5\u770b\u81ea\u5b9a\u4e49\u6a21\u677f\u662f\u5426\u6309\u9884\u671f\u5de5\u4f5c\u3002\u5982\u679c\u9700\u8981\uff0c\u4f60\u53ef\u4ee5\u7ee7\u7eed\u8c03\u6574HTML\u3001CSS\u548cPHP\u4ee3\u7801\uff0c\u4ee5\u4f18\u5316\u5e03\u5c40\u3001\u6837\u5f0f\u548c\u529f\u80fd\u3002<\/p>\n
\u901a\u8fc7\u521b\u5efa\u81ea\u5b9a\u4e49\u9996\u9875\u6a21\u677f\uff0c\u4f60\u53ef\u4ee5\u5b8c\u5168\u638c\u63a7WordPress\u7f51\u7ad9\u7684\u9996\u9875\u5185\u5bb9\uff0c\u5b9e\u73b0\u4e2a\u6027\u5316\u7684\u8bbe\u8ba1\u548c\u5e03\u5c40\uff0c\u4ece\u800c\u5438\u5f15\u66f4\u591a\u8bbf\u5ba2\u5e76\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002\u8bb0\u4f4f\uff0cWordPress\u7684\u7075\u6d3b\u6027\u548c\u5f3a\u5927\u7684\u793e\u533a\u652f\u6301\u610f\u5473\u7740\u51e0\u4e4e\u6ca1\u6709\u4ec0\u4e48\u662f\u4e0d\u53ef\u80fd\u7684\uff0c\u53ea\u8981\u4f60\u613f\u610f\u63a2\u7d22\u548c\u5c1d\u8bd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5728WordPress\u4e2d\u521b\u5efa\u81ea\u5b9a\u4e49\u9996\u9875\u6a21\u677f\uff0c\u662f\u63d0\u5347\u7f51\u7ad9\u4e2a\u6027\u5316\u4e0e\u7528\u6237\u4f53\u9a8c\u7684\u91cd\u8981\u6b65\u9aa4\u3002WordPress\u4ee5\u5176\u5f3a\u5927\u7684\u7075 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3250],"tags":[],"class_list":["post-259","post","type-post","status-publish","format-standard","hentry","category-jiaocheng"],"_links":{"self":[{"href":"http:\/\/www.woniuseo.com\/wordpress\/wp-json\/wp\/v2\/posts\/259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.woniuseo.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.woniuseo.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.woniuseo.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.woniuseo.com\/wordpress\/wp-json\/wp\/v2\/comments?post=259"}],"version-history":[{"count":1,"href":"http:\/\/www.woniuseo.com\/wordpress\/wp-json\/wp\/v2\/posts\/259\/revisions"}],"predecessor-version":[{"id":260,"href":"http:\/\/www.woniuseo.com\/wordpress\/wp-json\/wp\/v2\/posts\/259\/revisions\/260"}],"wp:attachment":[{"href":"http:\/\/www.woniuseo.com\/wordpress\/wp-json\/wp\/v2\/media?parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.woniuseo.com\/wordpress\/wp-json\/wp\/v2\/categories?post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.woniuseo.com\/wordpress\/wp-json\/wp\/v2\/tags?post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}