{"id":672,"date":"2013-01-06T23:53:13","date_gmt":"2013-01-06T15:53:13","guid":{"rendered":"https:\/\/sdeno.com\/?p=672"},"modified":"2013-01-09T14:05:00","modified_gmt":"2013-01-09T06:05:00","slug":"%e8%b0%83%e7%94%a8wordpress%e5%87%bd%e6%95%b0%e6%b1%87%e6%80%bb","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=672","title":{"rendered":"\u8c03\u7528wordpress\u51fd\u6570\u6c47\u603b"},"content":{"rendered":"<p><figure class=\"mdx-lazyload-container\" style=\"max-width:157px\"><div style=\"padding-top:74.522292993631%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"157\" height=\"117\" class=\"alignleft size-full wp-image-695 lazyload\" title=\"wp_photo\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2013\/01\/wp_photo.jpg\" alt=\"wp_photo\"><\/figure>WordPress\u6a21\u677f\u57fa\u672c\u6587\u4ef6<\/p>\n<p>style.css \u6837\u5f0f\u8868\u6587\u4ef6<br \/>\nindex.php \u4e3b\u9875\u6587\u4ef6<br \/>\nsingle.php \u65e5\u5fd7\u5355\u9875\u6587\u4ef6<br \/>\npage.php \u9875\u9762\u6587\u4ef6<br \/>\narchvie.php \u5206\u7c7b\u548c\u65e5\u671f\u5b58\u6863\u9875\u6587\u4ef6<br \/>\nsearchform.php \u641c\u7d22\u8868\u5355\u6587\u4ef6<br \/>\nsearch.php \u641c\u7d22\u9875\u9762\u6587\u4ef6<br \/>\ncomments.php \u7559\u8a00\u533a\u57df\u6587\u4ef6(\u5305\u62ec\u7559\u8a00\u5217\u8868\u548c\u7559\u8a00\u6846)<br \/>\n404.php 404\u9519\u8bef\u9875\u9762<br \/>\nheader.php \u7f51\u9875\u5934\u90e8\u6587\u4ef6<br \/>\nsidebar.php \u7f51\u9875\u4fa7\u8fb9\u680f\u6587\u4ef6<br \/>\nfooter.php \u7f51\u9875\u5e95\u90e8\u6587\u4ef6<\/p>\n<p>WordPress Header\u5934\u90e8 PHP\u4ee3\u7801<\/p>\n<p>\u6ce8: \u4e5f\u5c31\u662f\u4f4d\u4e8e&lt;head&gt;\u548c&lt;\/head&gt;\u4e4b\u95f4\u7684PHP\u4ee3\u7801<\/p>\n<p>&lt;?php bloginfo(\u2019name\u2019); ?&gt; \u7f51\u7ad9\u6807\u9898<br \/>\n&lt;?php wp_title(); ?&gt; \u65e5\u5fd7\u6216\u9875\u9762\u6807\u9898<br \/>\n&lt;?php bloginfo(\u2019stylesheet_url\u2019); ?&gt; WordPress\u4e3b\u9898\u6837\u5f0f\u8868\u6587\u4ef6style.css\u7684\u76f8\u5bf9\u5730\u5740<br \/>\n&lt;?php bloginfo(\u2019pingback_url\u2019); ?&gt; WordPress\u535a\u5ba2\u7684Pingback\u5730\u5740<br \/>\n&lt;?php bloginfo(\u2019template_url\u2019); ?&gt; WordPress\u4e3b\u9898\u6587\u4ef6\u7684\u76f8\u5bf9\u5730\u5740<br \/>\n&lt;?php bloginfo(\u2019version\u2019); ?&gt; \u535a\u5ba2\u7684WordPress\u7248\u672c<br \/>\n&lt;?php bloginfo(\u2019atom_url\u2019); ?&gt; WordPress\u535a\u5ba2\u7684Atom\u5730\u5740<br \/>\n&lt;?php bloginfo(\u2019rss2_url\u2019); ?&gt; WordPress\u535a\u5ba2\u7684RSS2\u5730\u5740<br \/>\n&lt;?php bloginfo(\u2019url\u2019); ?&gt; WordPress\u535a\u5ba2\u7684\u7edd\u5bf9\u5730\u5740<br \/>\n&lt;?php bloginfo(\u2019name\u2019); ?&gt; WordPress\u535a\u5ba2\u7684\u540d\u79f0<br \/>\n&lt;?php bloginfo(\u2019html_type\u2019); ?&gt; \u7f51\u7ad9\u7684HTML\u7248\u672c<br \/>\n&lt;?php bloginfo(\u2019charset\u2019); ?&gt; \u7f51\u7ad9\u7684\u5b57\u7b26\u7f16\u7801\u683c\u5f0f<\/p>\n<p>WordPress \u4e3b\u4f53\u6a21\u677f PHP\u4ee3\u7801<\/p>\n<p>&lt;?php the_content(); ?&gt; \u65e5\u5fd7\u5185\u5bb9<br \/>\n&lt;?php if(have_posts()) : ?&gt; \u786e\u8ba4\u662f\u5426\u6709\u65e5\u5fd7<br \/>\n&lt;?php while(have_posts()) : the_post(); ?&gt; \u5982\u679c\u6709\uff0c\u5219\u663e\u793a\u5168\u90e8\u65e5\u5fd7<br \/>\n&lt;?php endwhile; ?&gt; \u7ed3\u675fPHP\u51fd\u6570\u201dwhile\u201d<br \/>\n&lt;?php endif; ?&gt; \u7ed3\u675fPHP\u51fd\u6570\u201dif\u201d<br \/>\n&lt;?php get_header(); ?&gt; header.php\u6587\u4ef6\u7684\u5185\u5bb9<br \/>\n&lt;?php get_sidebar(); ?&gt; sidebar.php\u6587\u4ef6\u7684\u5185\u5bb9<br \/>\n&lt;?php get_footer(); ?&gt; footer.php\u6587\u4ef6\u7684\u5185\u5bb9<br \/>\n&lt;?php the_time(\u2019m-d-y\u2019) ?&gt; \u663e\u793a\u683c\u5f0f\u4e3a\u201d02-19-08\u2033\u7684\u65e5\u671f<br \/>\n&lt;?php comments_popup_link(); ?&gt; \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u7684\u7559\u8a00\u94fe\u63a5<br \/>\n&lt;?php the_title(); ?&gt; \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684\u6807\u9898<br \/>\n&lt;?php the_permalink() ?&gt; \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684\u6c38\u4e45\u94fe\u63a5\/URL\u5730\u5740<br \/>\n&lt;?php the_category(\u2019, \u2018) ?&gt; \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684\u6240\u5c5e\u5206\u7c7b<br \/>\n&lt;?php the_author(); ?&gt; \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684\u4f5c\u8005<br \/>\n&lt;?php the_ID(); ?&gt; \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684ID<br \/>\n&lt;?php edit_post_link(); ?&gt; \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684\u7f16\u8f91\u94fe\u63a5<br \/>\n&lt;?php get_links_list(); ?&gt; \u663e\u793aBlogroll\u4e2d\u7684\u94fe\u63a5<br \/>\n&lt;?php comments_template(); ?&gt; comments.php\u6587\u4ef6\u7684\u5185\u5bb9<br \/>\n&lt;?php wp_list_pages(); ?&gt; \u663e\u793a\u4e00\u4efd\u535a\u5ba2\u7684\u9875\u9762\u5217\u8868<br \/>\n&lt;?php wp_list_cats(); ?&gt; \u663e\u793a\u4e00\u4efd\u535a\u5ba2\u7684\u5206\u7c7b\u5217\u8868<br \/>\n&lt;?php next_post_link(\u2019 %link \u2018) ?&gt; \u4e0b\u4e00\u7bc7\u65e5\u5fd7\u7684URL\u5730\u5740<br \/>\n&lt;?php previous_post_link(\u2019%link\u2019) ?&gt; \u4e0a\u4e00\u7bc7\u65e5\u5fd7\u7684URL\u5730\u5740<br \/>\n&lt;?php get_calendar(); ?&gt; \u8c03\u7528\u65e5\u5386<br \/>\n&lt;?php wp_get_archives() ?&gt; \u663e\u793a\u4e00\u4efd\u535a\u5ba2\u7684\u65e5\u671f\u5b58\u6863\u5217\u8868<br \/>\n&lt;?php posts_nav_link(); ?&gt; \u663e\u793a\u8f83\u65b0\u65e5\u5fd7\u94fe\u63a5(\u4e0a\u4e00\u9875)\u548c\u8f83\u65e7\u65e5\u5fd7\u94fe\u63a5\uff08\u4e0b\u4e00\u9875\uff09<br \/>\n&lt;?php bloginfo(\u2019description\u2019); ?&gt; \u663e\u793a\u535a\u5ba2\u7684\u63cf\u8ff0\u4fe1\u606f<\/p>\n<p>\u5176\u5b83\u7684\u4e00\u4e9bWordPress\u6a21\u677f\u4ee3\u7801<\/p>\n<p>\/%postname%\/ \u663e\u793a\u535a\u5ba2\u7684\u81ea\u5b9a\u4e49\u6c38\u4e45\u94fe\u63a5<br \/>\n&lt;?php the_search_query(); ?&gt; \u641c\u7d22\u8868\u5355\u7684\u503c<br \/>\n&lt;?php _e(\u2019Message\u2019); ?&gt; \u6253\u5370\u8f93\u51fa\u4fe1\u606f<br \/>\n&lt;?php wp_register(); ?&gt; \u663e\u793a\u6ce8\u518c\u94fe\u63a5<br \/>\n&lt;?php wp_loginout(); ?&gt; \u663e\u793a\u767b\u5165\/\u767b\u51fa\u94fe\u63a5<br \/>\n&lt;!\u2013next page\u2013&gt; \u5728\u65e5\u5fd7\u6216\u9875\u9762\u4e2d\u63d2\u5165\u5206\u9875<br \/>\n&lt;!\u2013more\u2013&gt; \u622a\u65ad\u65e5\u5fd7<br \/>\n&lt;?php wp_meta(); ?&gt; \u663e\u793a\u7ba1\u7406\u5458\u7684\u76f8\u5173\u63a7\u5236\u4fe1\u606f<br \/>\n&lt;?php timer_stop(1); ?&gt; \u663e\u793a\u8f7d\u5165\u9875\u9762\u7684\u65f6\u95f4<br \/>\n&lt;?php echo get_num_queries(); ?&gt; \u663e\u793a\u8f7d\u5165\u9875\u9762\u67e5\u8be2<\/p>\n<p>1. wordpress\u8c03\u7528\u6700\u65b0\u6587\u7ae0<\/p>\n<p>WordPress\u6700\u65b0\u6587\u7ae0\u7684\u8c03\u7528\u53ef\u4ee5\u4f7f\u7528\u4e00\u884c\u5f88\u7b80\u5355\u7684\u6a21\u677f\u6807\u7b7ewp_get_archvies\u6765\u5b9e\u73b0. \u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>&lt;?php get_archives(\u2018postbypost\u2019, 10); ?&gt; (\u663e\u793a10\u7bc7\u6700\u65b0\u66f4\u65b0\u6587\u7ae0)<\/p>\n<p>\u6216\u8005<\/p>\n<p>&lt;?php wp_get_archives(\u2018type=postbypost&amp;limit=20&amp;format=custom\u2019); ?&gt;<\/p>\n<p>\u540e\u9762\u8fd9\u4e2a\u4ee3\u7801\u663e\u793a\u4f60\u535a\u5ba2\u4e2d\u6700\u65b0\u768420\u7bc7\u6587\u7ae0\uff0c\u5176\u4e2dformat=custom\u8fd9\u91cc\u4e3b\u8981\u7528\u6765\u81ea\u5b9a\u4e49\u8fd9\u4efd\u6587\u7ae0\u5217\u8868\u7684\u663e\u793a\u6837\u5f0f\u3002\u5177\u4f53\u7684\u53c2\u6570\u548c\u4f7f\u7528\u65b9\u6cd5\u4f60\u53ef \u4ee5\u53c2\u8003\u5b98\u65b9\u7684\u4f7f\u7528\u8bf4\u660e- wp_get_archvies\u3002(fromat=custom\u4e5f\u53ef\u4ee5\u4e0d\u8981\uff0c\u9ed8\u8ba4\u4ee5UL\u5217\u8868\u663e\u793a\u6587\u7ae0\u6807\u9898\u3002)<\/p>\n<p>\u8865\u5145: \u901a\u8fc7WP\u7684query_posts()\u51fd\u6570\u4e5f\u80fd\u8c03\u7528\u6700\u65b0\u6587\u7ae0\u5217\u8868\uff0c \u867d\u7136\u4ee3\u7801\u4f1a\u6bd4\u8f83\u591a\u4e00\u70b9\uff0c\u4f46\u53ef\u4ee5\u66f4\u597d\u7684\u63a7\u5236Loop\u7684\u663e\u793a\uff0c\u6bd4\u5982\u4f60\u53ef\u4ee5\u8bbe\u7f6e\u662f\u5426\u663e\u793a\u6458\u8981\u3002\u5177\u4f53\u7684\u4f7f\u7528\u65b9\u6cd5\u4e5f\u53ef\u4ee5\u67e5\u770b\u5b98\u65b9\u7684\u8bf4\u660e\u3002<\/p>\n<p>2. wordpress\u8c03\u7528\u968f\u673a\u6587\u7ae0<\/p>\n<p>&lt;?php<br \/>\n$rand_posts = get_posts(\u2018numberposts=10&amp;orderby=rand\u2019);<br \/>\nforeach( $rand_posts as $post ) :<br \/>\n?&gt;<br \/>\n&lt;!\u2013\u4e0b\u9762\u662f\u4f60\u60f3\u81ea\u5b9a\u4e49\u7684Loop\u2013&gt;<br \/>\n&lt;li&gt;&lt;a href=\u201d&lt;?php the_permalink(); ?&gt;\u201d&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;?php endforeach; ?&gt;<\/p>\n<p>3. wordpress\u8c03\u7528\u6700\u65b0\u7559\u8a00<\/p>\n<p>\u4e0b\u9762\u662f\u6211\u4e4b\u524d\u5728\u4e00\u4e2aWordPress\u4e3b\u9898\u4e2d\u4ee3\u5230\u7684\u6700\u65b0\u7559\u8a00\u4ee3\u7801\uff0c\u5177\u4f53\u4e5f\u8bb0\u4e0d\u5f97\u662f\u54ea\u4e2a\u4e3b\u9898\u4e86\u3002\u8be5\u4ee3\u7801\u76f4\u63a5\u8c03\u7528\u6570\u636e\u5e93\u663e\u793a\u4e00\u4efd\u6700\u65b0\u7559\u8a00\u3002\u5176\u4e2d LIMIT 10\u9650\u5236\u7559\u8a00\u663e\u793a\u6570\u91cf\u3002\u7eff\u8272\u90e8\u4efd\u5219\u662f\u6bcf\u6761\u7559\u8a00\u7684\u8f93\u51fa\u6837\u5f0f\u3002<\/p>\n<p>&lt;?php<br \/>\nglobal $wpdb;<br \/>\n$sql = \u201cSELECT DISTINCT ID, post_title, post_password, comment_ID,<br \/>\ncomment_post_ID, comment_author, comment_date_gmt, comment_approved,<br \/>\ncomment_type,comment_author_url,<br \/>\nSUBSTRING(comment_content,1,30) AS com_excerpt<br \/>\nFROM $wpdb-&gt;comments<br \/>\nLEFT OUTER JOIN $wpdb-&gt;posts ON ($wpdb-&gt;comments.comment_post_ID =<br \/>\n$wpdb-&gt;posts.ID)<br \/>\nWHERE comment_approved = \u20191\u2032 AND comment_type = \u201d AND<br \/>\npost_password = \u201d<br \/>\nORDER BY comment_date_gmt DESC<br \/>\nLIMIT 10\u2033;<br \/>\n$comments = $wpdb-&gt;get_results($sql);<br \/>\n$output = $pre_HTML; foreach ($comments as $comment) {<br \/>\n$output .= \u201cn&lt;li&gt;\u201d.strip_tags($comment-&gt;comment_author)<br \/>\n.\u201d:\u201d . \u201d &lt;a href=\u201d&#8221; . get_permalink($comment-&gt;ID) .<br \/>\n\u201c#comment-\u201d . $comment-&gt;comment_ID . \u201c\u201d title=\u201don \u201d .<br \/>\n$comment-&gt;post_title . \u201c\u201d&gt;\u201d . strip_tags($comment-&gt;com_excerpt)<br \/>\n.\u201d&lt;\/a&gt;&lt;\/li&gt;\u201d;<br \/>\n} $output .= $post_HTML;<br \/>\necho $output;?&gt;<\/p>\n<p>4.wordpress\u8c03\u7528\u76f8\u5173\u6587\u7ae0<\/p>\n<p>\u5728\u6587\u7ae0\u9875\u663e\u793a\u76f8\u5173\u6587\u7ae0<\/p>\n<p>&lt;?php<\/p>\n<p>$tags = wp_get_post_tags($post-&gt;ID);<\/p>\n<p>if ($tags) {<\/p>\n<p>$first_tag = $tags[0]-&gt;term_id;<\/p>\n<p>$args=array(<\/p>\n<p>\u2018tag__in\u2019 =&gt; array($first_tag),<\/p>\n<p>\u2018post__not_in\u2019 =&gt; array($post-&gt;ID),<\/p>\n<p>\u2018showposts\u2019=&gt;10,<\/p>\n<p>\u2018caller_get_posts\u2019=&gt;1<\/p>\n<p>);<\/p>\n<p>$my_query = new WP_Query($args);<\/p>\n<p>if( $my_query-&gt;have_posts() ) {<\/p>\n<p>while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt;<\/p>\n<p>&lt;li&gt;&lt;a href=\u201d&lt;?php the_permalink() ?&gt;\u201d rel=\u201dbookmark\u201d title=\u201d&lt;?php the_title_attribute(); ?&gt;\u201d&gt;&lt;?php the_title();?&gt; &lt;?php comments_number(\u2018 \u2018,\u2019(1)\u2019,'(%)\u2019); ?&gt;&lt;\/a&gt;&lt;\/li&gt;<\/p>\n<p>&lt;?php<\/p>\n<p>endwhile;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>wp_reset_query();<\/p>\n<p>?&gt;<\/p>\n<p>5.wordpress\u8c03\u7528\u6307\u5b9a\u5206\u7c7b\u7684\u6587\u7ae0<\/p>\n<p>&lt;?php $posts = get_posts( \u201ccategory=4&amp;numberposts=10\u2033 ); ?&gt;<br \/>\n&lt;?php if( $posts ) : ?&gt;<br \/>\n&lt;ul&gt;&lt;?php foreach( $posts as $post ) : setup_postdata( $post ); ?&gt;<br \/>\n&lt;li&gt;<br \/>\n&lt;a href=\u201d&lt;?php the_permalink() ?&gt;\u201d rel=\u201dbookmark\u201d title=\u201d&lt;?php the_title(); ?&gt;\u201d&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;<br \/>\n&lt;\/li&gt;<br \/>\n&lt;?php endforeach; ?&gt;<br \/>\n&lt;\/ul&gt;<br \/>\n&lt;?php endif; ?&gt;<\/p>\n<p>6.wordpress\u53bb\u8bc4\u8bba\u8005\u94fe\u63a5\u7684\u8bc4\u8bba\u8f93\u51fa<\/p>\n<p>&lt;?php<\/p>\n<p>global $wpdb;<\/p>\n<p>$sql = \u201cSELECT DISTINCT ID, post_title, post_password, comment_ID,<\/p>\n<p>comment_post_ID, comment_author, comment_date_gmt, comment_approved,<\/p>\n<p>comment_type,comment_author_url,<\/p>\n<p>SUBSTRING(comment_content,1,14) AS com_excerpt<\/p>\n<p>FROM $wpdb-&gt;comments<\/p>\n<p>LEFT OUTER JOIN $wpdb-&gt;posts ON ($wpdb-&gt;comments.comment_post_ID =<\/p>\n<p>$wpdb-&gt;posts.ID)<\/p>\n<p>WHERE comment_approved = \u20191\u2032 AND comment_type = \u201d AND<\/p>\n<p>post_password = \u201d<\/p>\n<p>ORDER BY comment_date_gmt DESC<\/p>\n<p>LIMIT 10\u2033;<\/p>\n<p>$comments = $wpdb-&gt;get_results($sql);<\/p>\n<p>$output = $pre_HTML;<\/p>\n<p>foreach ($comments as $comment) {<\/p>\n<p>$output .= \u201c\\n&lt;li&gt;\u201d.strip_tags($comment-&gt;comment_author)<\/p>\n<p>.\u201d:\u201d . \u201d &lt;a href=\\\u201d&#8221; . get_permalink($comment-&gt;ID) .<\/p>\n<p>\u201c#comment-\u201d . $comment-&gt;comment_ID . \u201c\\\u201d title=\\\u201don \u201d .<\/p>\n<p>$comment-&gt;post_title . \u201c\\\u201d&gt;\u201d . strip_tags($comment-&gt;com_excerpt)<\/p>\n<p>.\u201d&lt;\/a&gt;&lt;\/li&gt;\u201d;<\/p>\n<p>}<\/p>\n<p>$output .= $post_HTML;<\/p>\n<p>echo $output;?&gt;<\/p>\n<p>7.wordpress\u8c03\u7528\u542bgravatar\u5934\u50cf\u7684\u8bc4\u8bba\u8f93\u51fa<\/p>\n<p>&lt;?php<\/p>\n<p>global $wpdb;<\/p>\n<p>$sql = \u201cSELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,10) AS com_excerpt FROM $wpdb-&gt;comments LEFT OUTER JOIN $wpdb-&gt;posts ON ($wpdb-&gt;comments.comment_post_ID = $wpdb-&gt;posts.ID) WHERE comment_approved = \u20191\u2032 AND comment_type = \u201d AND comment_author != \u2018\u90d1 \u6c38\u2019 AND post_password = \u201d ORDER BY comment_date_gmt DESC LIMIT 10\u2033;<\/p>\n<p>$comments = $wpdb-&gt;get_results($sql);<\/p>\n<p>$output = $pre_HTML;<\/p>\n<p>foreach ($comments as $comment) {<\/p>\n<p>$output .= \u201c\\n&lt;li&gt;\u201d.get_avatar(get_comment_author_email(\u2018comment_author_email\u2019), 18). \u201d &lt;a href=\\\u201d&#8221; . get_permalink($comment-&gt;ID) . \u201c#comment-\u201d . $comment-&gt;comment_ID . \u201c\\\u201d title=\\\u201d&#8221; . $comment-&gt;post_title . \u201d \u4e0a\u7684\u8bc4\u8bba\\\u201d&gt;\u201d. strip_tags($comment-&gt;comment_author) .\u201d\uff1a \u201c. strip_tags($comment-&gt;com_excerpt) .\u201d&lt;\/a&gt;&lt;\/li&gt;\u201d;<\/p>\n<p>}<\/p>\n<p>$output .= $post_HTML;<\/p>\n<p>$output = convert_smilies($output);<\/p>\n<p>echo $output;<\/p>\n<p>?&gt;<\/p>\n<p>\u4e0a\u9762\u4ee3\u7801\u628acomment_author\u7684\u503c\u6539\u6210\u4f60\u7684ID\uff0c18\u662f\u5934\u50cf\u5927\u5c0f\uff0c10\u662f\u8bc4\u8bba\u6570\u91cf\u3002<\/p>\n<p>8.wordpress\u8c03\u7528\u7f51\u7ad9\u7edf\u8ba1\u5927\u5168<\/p>\n<p>1\u3001\u65e5\u5fd7\u603b\u6570\uff1a<\/p>\n<p>&lt;?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts-&gt;publish;?&gt;<\/p>\n<p>2\u3001\u8349\u7a3f\u6570\u76ee\uff1a<\/p>\n<p>&lt;?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts-&gt;draft; ?&gt;<\/p>\n<p>3\u3001\u8bc4\u8bba\u603b\u6570\uff1a<\/p>\n<p>&lt;?php echo $wpdb-&gt;get_var(\u201cSELECT COUNT(*) FROM $wpdb-&gt;comments\u201d);?&gt;<\/p>\n<p>4\u3001\u6210\u7acb\u65f6\u95f4\uff1a<\/p>\n<p>&lt;?php echo floor((time()-strtotime(\u201c2008-8-18\u2033))\/86400); ?&gt;<\/p>\n<p>5\u3001\u6807\u7b7e\u603b\u6570\uff1a<\/p>\n<p>&lt;?php echo $count_tags = wp_count_terms(\u2018post_tag\u2019); ?&gt;<\/p>\n<p>6\u3001\u9875\u9762\u603b\u6570\uff1a<\/p>\n<p>&lt;?php $count_pages = wp_count_posts(\u2018page\u2019); echo $page_posts = $count_pages-&gt;publish; ?&gt;<\/p>\n<p>7\u3001\u5206\u7c7b\u603b\u6570\uff1a<\/p>\n<p>&lt;?php echo $count_categories = wp_count_terms(\u2018category\u2019); ?&gt;<\/p>\n<p>8\u3001\u94fe\u63a5\u603b\u6570\uff1a<\/p>\n<p>&lt;?php $link = $wpdb-&gt;get_var(\u201cSELECT COUNT(*) FROM $wpdb-&gt;links WHERE link_visible = \u2018Y\u2019\u201d); echo $link; ?&gt;<\/p>\n<p>9\u3001\u7528\u6237\u603b\u6570\uff1a<\/p>\n<p>&lt;?php $users = $wpdb-&gt;get_var(\u201cSELECT COUNT(ID) FROM $wpdb-&gt;users\u201d); echo $users; ?&gt;<\/p>\n<p>10\u3001\u6700\u540e\u66f4\u65b0\uff1a<\/p>\n<p>&lt;?php $last = $wpdb-&gt;get_results(\u201cSELECT MAX(post_modified) AS MAX_m FROM $wpdb-&gt;posts WHERE (post_type = \u2018post\u2019 OR post_type = \u2018page\u2019) AND (post_status = \u2018publish\u2019 OR post_status = \u2018private\u2019)\u201d);$last = date(\u2018Y-n-j\u2019, strtotime($last[0]-&gt;MAX_m));echo $last; ?&gt;<\/p>\n<p>9.wordpress\u5224\u65ad\u8bed\u53e5<\/p>\n<p>is_single()<\/p>\n<p>\u5224\u65ad\u662f\u5426\u662f\u5177\u4f53\u6587\u7ae0\u7684\u9875\u9762<\/p>\n<p>is_single(\u20192\u2032)<\/p>\n<p>\u5224\u65ad\u662f\u5426\u662f\u5177\u4f53\u6587\u7ae0\uff08id=2\uff09\u7684\u9875\u9762<\/p>\n<p>is_single(\u2019Beef Stew\u2019)<\/p>\n<p>\u5224\u65ad\u662f\u5426\u662f\u5177\u4f53\u6587\u7ae0\uff08\u6807\u9898\u5224\u65ad\uff09\u7684\u9875\u9762<\/p>\n<p>is_single(\u2019beef-stew\u2019)<\/p>\n<p>\u5224\u65ad\u662f\u5426\u662f\u5177\u4f53\u6587\u7ae0\uff08slug\u5224\u65ad\uff09\u7684\u9875\u9762<\/p>\n<p>comments_open()<\/p>\n<p>\u662f\u5426\u7559\u8a00\u5f00\u542f<\/p>\n<p>pings_open()<\/p>\n<p>\u662f\u5426\u5f00\u542fping<\/p>\n<p>is_page()<\/p>\n<p>\u662f\u5426\u662f\u9875\u9762<\/p>\n<p>is_page(\u201942\u2032)<\/p>\n<p>id\u5224\u65ad\uff0c\u5373\u662f\u5426\u662fid\u4e3a42\u7684\u9875\u9762<\/p>\n<p>is_page(\u2019About Me\u2019)<\/p>\n<p>\u5224\u65ad\u6807\u9898<\/p>\n<p>is_page(\u2019about-me\u2019)<\/p>\n<p>slug\u5224\u65ad<\/p>\n<p>is_category()<\/p>\n<p>\u662f\u5426\u662f\u5206\u7c7b<\/p>\n<p>is_category(\u20196\u2032)<\/p>\n<p>id\u5224\u65ad\uff0c\u5373\u662f\u5426\u662fid\u4e3a6\u7684\u5206\u7c7b<\/p>\n<p>is_category(\u2019Cheeses\u2019)<\/p>\n<p>\u5206\u7c7btitle\u5224\u65ad<\/p>\n<p>is_category(\u2019cheeses\u2019)<\/p>\n<p>\u5206\u7c7b slug\u5224\u65ad<\/p>\n<p>in_category(\u20195\u2032)<\/p>\n<p>\u5224\u65ad\u5f53\u524d\u7684\u6587\u7ae0\u662f\u5426\u5c5e\u4e8e\u5206\u7c7b5<\/p>\n<p>is_author()<\/p>\n<p>\u5c06\u6240\u6709\u7684\u4f5c\u8005\u7684\u9875\u9762\u663e\u793a\u51fa\u6765<\/p>\n<p>is_author(\u20191337\u2032)<\/p>\n<p>\u663e\u793aauthor number\u4e3a1337\u7684\u9875\u9762<\/p>\n<p>is_author(\u2019Elite Hacker\u2019)<\/p>\n<p>\u901a\u8fc7\u6635\u79f0\u6765\u663e\u793a\u5f53\u524d\u4f5c\u8005\u7684\u9875\u9762<\/p>\n<p>is_author(\u2019elite-hacker\u2019)<\/p>\n<p>\u4e0b\u9762\u662f\u901a\u8fc7\u4e0d\u540c\u7684\u5224\u65ad\u5b9e\u73b0\u4ee5\u5e74\u3001\u6708\u3001\u65e5\u3001\u65f6\u95f4\u7b49\u65b9\u5f0f\u6765\u663e\u793a\u5f52\u6863<\/p>\n<p>is_date()<\/p>\n<p>is_year()<\/p>\n<p>is_month()<\/p>\n<p>is_day()<\/p>\n<p>is_time()<\/p>\n<p>\u5224\u65ad\u5f53\u524d\u662f\u5426\u662f\u5f52\u6863\u9875\u9762<\/p>\n<p>is_archive()<\/p>\n<p>\u5224\u65ad\u662f\u5426\u662f\u641c\u7d22<\/p>\n<p>is_search()<\/p>\n<p>\u5224\u65ad\u9875\u9762\u662f\u5426404<\/p>\n<p>is_404()<\/p>\n<p>\u5224\u65ad\u662f\u5426\u7ffb\u9875\uff0c\u6bd4\u5982\u4f60\u5f53\u524d\u7684blog\u662fhttp:\/\/domain.com \u663e\u793ahttp:\/\/domain.com?paged=2\u7684\u65f6\u5019\uff0c\u8fd9\u4e2a\u5224\u65ad\u5c06\u8fd4 \u56de\u771f\uff0c\u901a\u8fc7\u8fd9\u4e2a\u51fd\u6570\u53ef\u4ee5\u914d\u5408is_home\u6765\u63a7\u5236\u67d0\u4e9b\u53ea\u80fd\u5728\u9996\u9875\u663e\u793a\u7684\u754c\u9762\uff0c<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>&lt;?php if(is_single()):?&gt;<\/p>\n<p>\/\/\u8fd9\u91cc\u5199\u4f60\u60f3\u663e\u793a\u7684\u5185\u5bb9\uff0c\u5305\u62ec\u51fd\u6570<\/p>\n<p>&lt;?php endif;?&gt;<\/p>\n<p>\u6216\u8005\uff1a<\/p>\n<p>&lt;?php if(is_home() &amp;&amp; !is_paged() ):?&gt;<\/p>\n<p>\/\/\u8fd9\u91cc\u5199\u4f60\u60f3\u663e\u793a\u7684\u5185\u5bb9\uff0c\u5305\u62ec\u51fd\u6570<\/p>\n<p>&lt;?php endif;?&gt;<\/p>\n<p>10.wordpress \u975e\u63d2\u4ef6\u8c03\u7528\u8bc4\u8bba\u8868\u60c5<\/p>\n<p>&lt;!\u2013smilies\u2013&gt;<br \/>\n&lt;?php<\/p>\n<p>function wp_smilies() {<\/p>\n<p>global $wpsmiliestrans;<\/p>\n<p>if ( !get_option(\u2018use_smilies\u2019) or (empty($wpsmiliestrans))) return;<\/p>\n<p>$smilies = array_unique($wpsmiliestrans);<\/p>\n<p>$link=\u201d;<\/p>\n<p>foreach ($smilies as $key =&gt; $smile) {<\/p>\n<p>$file = get_bloginfo(\u2018wpurl\u2019).\u2019\/wp-includes\/images\/smilies\/\u2019.$smile;<\/p>\n<p>$value = \u201d \u201c.$key.\u201d \u201c;<\/p>\n<p>$img = \u201c&lt;img src=\\\u201d{$file}\\\u201d alt=\\\u201d{$smile}\\\u201d \/&gt;\u201d;<\/p>\n<p>$imglink = htmlspecialchars($img);<\/p>\n<p>$link .= \u201c&lt;a href=\\\u201d#commentform\\\u201d title=\\\u201d{$smile}\\\u201d onclick=\\\u201ddocument.getElementById(\u2018comment\u2019).value += \u2018{$value}\u2019\\\u201d&gt;{$img}&lt;\/a&gt;&amp;nbsp;\u201d;<\/p>\n<p>}<\/p>\n<p>echo \u2018&lt;div&gt;\u2019.$link.\u2019&lt;\/div&gt;\u2019;<\/p>\n<p>}<\/p>\n<p>?&gt;<\/p>\n<p>&lt;?php wp_smilies();?&gt;<\/p>\n<p>&lt;!\u2013smilies\u2014&gt;<\/p>\n<p>\u5c06\u4ee5\u4e0a\u4ee3\u7801\u590d\u5236\u5230 comments.php \u4e2d\u5408\u9002\u7684\u4f4d\u7f6e\uff1a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u6a21\u677f\u57fa\u672c\u6587\u4ef6 style.css \u6837\u5f0f\u8868\u6587\u4ef6 index.php \u4e3b\u9875\u6587\u4ef6 single.p [&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-672","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\/672","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=672"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/672\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}