{"id":361,"date":"2013-06-13T17:58:04","date_gmt":"2013-06-13T09:58:04","guid":{"rendered":"http:\/\/www.cnmiss.cn\/?p=361"},"modified":"2013-06-13T18:56:30","modified_gmt":"2013-06-13T10:56:30","slug":"wordpress-%e5%87%bd%e6%95%b0%e8%b0%83%e7%94%a8%e5%a4%a7%e5%85%a8","status":"publish","type":"post","link":"https:\/\/www.cnmiss.cn\/?p=361","title":{"rendered":"WordPress \u51fd\u6570\u8c03\u7528\u5927\u5168"},"content":{"rendered":"<p><strong>WordPress\u6a21\u677f\u57fa\u672c\u6587\u4ef6<\/strong><\/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><strong>WordPress Header\u5934\u90e8 PHP\u4ee3\u7801<\/strong><\/p>\n<p>\u6ce8: \u4e5f\u5c31\u662f\u4f4d\u4e8e<head>\u548c<\/head>\u4e4b\u95f4\u7684PHP\u4ee3\u7801<\/p>\n<pre>\r\n<?php bloginfo('name'); ?> \u7f51\u7ad9\u6807\u9898\r\n<?php wp_title(); ?> \u65e5\u5fd7\u6216\u9875\u9762\u6807\u9898\r\n<?php bloginfo('stylesheet_url'); ?> WordPress\u4e3b\u9898\u6837\u5f0f\u8868\u6587\u4ef6style.css\u7684\u76f8\u5bf9\u5730\u5740\r\n<?php bloginfo('pingback_url'); ?> WordPress\u535a\u5ba2\u7684Pingback\u5730\u5740\r\n<?php bloginfo('template_url'); ?> WordPress\u4e3b\u9898\u6587\u4ef6\u7684\u76f8\u5bf9\u5730\u5740\r\n<?php bloginfo('version'); ?> \u535a\u5ba2\u7684WordPress\u7248\u672c\r\n<?php bloginfo('atom_url'); ?> WordPress\u535a\u5ba2\u7684Atom\u5730\u5740\r\n<?php bloginfo('rss2_url'); ?> WordPress\u535a\u5ba2\u7684RSS2\u5730\u5740\r\n<?php bloginfo('url'); ?> WordPress\u535a\u5ba2\u7684\u7edd\u5bf9\u5730\u5740\r\n<?php bloginfo('name'); ?> WordPress\u535a\u5ba2\u7684\u540d\u79f0\r\n<?php bloginfo('html_type'); ?> \u7f51\u7ad9\u7684HTML\u7248\u672c\r\n<?php bloginfo('charset'); ?> \u7f51\u7ad9\u7684\u5b57\u7b26\u7f16\u7801\u683c\u5f0f\r\n<\/pre>\n<p><strong>WordPress \u4e3b\u4f53\u6a21\u677f PHP\u4ee3\u7801<\/strong><\/p>\n<pre>\r\n<?php the_content(); ?> \u65e5\u5fd7\u5185\u5bb9\r\n<?php if(have_posts()) : ?> \u786e\u8ba4\u662f\u5426\u6709\u65e5\u5fd7\r\n<?php while(have_posts()) : the_post(); ?> \u5982\u679c\u6709\uff0c\u5219\u663e\u793a\u5168\u90e8\u65e5\u5fd7\r\n<?php endwhile; ?> \u7ed3\u675fPHP\u51fd\u6570\"while\"\r\n<?php endif; ?> \u7ed3\u675fPHP\u51fd\u6570\"if\"\r\n<?php get_header(); ?> header.php\u6587\u4ef6\u7684\u5185\u5bb9\r\n<?php get_sidebar(); ?> sidebar.php\u6587\u4ef6\u7684\u5185\u5bb9\r\n<?php get_footer(); ?> footer.php\u6587\u4ef6\u7684\u5185\u5bb9\r\n<?php the_time('m-d-y') ?> \u663e\u793a\u683c\u5f0f\u4e3a\"02-19-08\"\u7684\u65e5\u671f\r\n<?php comments_popup_link(); ?> \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u7684\u7559\u8a00\u94fe\u63a5\r\n<?php the_title(); ?> \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684\u6807\u9898\r\n<?php the_permalink() ?> \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684\u6c38\u4e45\u94fe\u63a5\/URL\u5730\u5740\r\n<?php the_category(', ') ?> \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684\u6240\u5c5e\u5206\u7c7b\r\n<?php the_author(); ?> \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684\u4f5c\u8005\r\n<?php the_ID(); ?> \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684ID\r\n<?php edit_post_link(); ?> \u663e\u793a\u4e00\u7bc7\u65e5\u5fd7\u6216\u9875\u9762\u7684\u7f16\u8f91\u94fe\u63a5\r\n<?php get_links_list(); ?> \u663e\u793aBlogroll\u4e2d\u7684\u94fe\u63a5\r\n<?php comments_template(); ?> comments.php\u6587\u4ef6\u7684\u5185\u5bb9\r\n<?php wp_list_pages(); ?> \u663e\u793a\u4e00\u4efd\u535a\u5ba2\u7684\u9875\u9762\u5217\u8868\r\n<?php wp_list_cats(); ?> \u663e\u793a\u4e00\u4efd\u535a\u5ba2\u7684\u5206\u7c7b\u5217\u8868\r\n<?php next_post_link(' %link ') ?> \u4e0b\u4e00\u7bc7\u65e5\u5fd7\u7684URL\u5730\u5740\r\n<?php previous_post_link('%link') ?> \u4e0a\u4e00\u7bc7\u65e5\u5fd7\u7684URL\u5730\u5740\r\n<?php get_calendar(); ?> \u8c03\u7528\u65e5\u5386\r\n<?php wp_get_archives() ?> \u663e\u793a\u4e00\u4efd\u535a\u5ba2\u7684\u65e5\u671f\u5b58\u6863\u5217\u8868\r\n<?php posts_nav_link(); ?> \u663e\u793a\u8f83\u65b0\u65e5\u5fd7\u94fe\u63a5(\u4e0a\u4e00\u9875)\u548c\u8f83\u65e7\u65e5\u5fd7\u94fe\u63a5\uff08\u4e0b\u4e00\u9875\uff09\r\n<?php bloginfo('description'); ?> \u663e\u793a\u535a\u5ba2\u7684\u63cf\u8ff0\u4fe1\u606f\r\n<\/pre>\n<p><strong>\u5176\u5b83\u7684\u4e00\u4e9bWordPress\u6a21\u677f\u4ee3\u7801<\/strong><\/p>\n<pre>\r\n\/%postname%\/ \u663e\u793a\u535a\u5ba2\u7684\u81ea\u5b9a\u4e49\u6c38\u4e45\u94fe\u63a5\r\n<?php the_search_query(); ?> \u641c\u7d22\u8868\u5355\u7684\u503c\r\n<?php _e('Message'); ?> \u6253\u5370\u8f93\u51fa\u4fe1\u606f\r\n<?php wp_register(); ?> \u663e\u793a\u6ce8\u518c\u94fe\u63a5\r\n<?php wp_loginout(); ?> \u663e\u793a\u767b\u5165\/\u767b\u51fa\u94fe\u63a5\r\n<!\u2013next page\u2013> \u5728\u65e5\u5fd7\u6216\u9875\u9762\u4e2d\u63d2\u5165\u5206\u9875\r\n<!\u2013more\u2013> \u622a\u65ad\u65e5\u5fd7\r\n<?php wp_meta(); ?> \u663e\u793a\u7ba1\u7406\u5458\u7684\u76f8\u5173\u63a7\u5236\u4fe1\u606f\r\n<?php timer_stop(1); ?> \u663e\u793a\u8f7d\u5165\u9875\u9762\u7684\u65f6\u95f4\r\n<?php echo get_num_queries(); ?> \u663e\u793a\u8f7d\u5165\u9875\u9762\u67e5\u8be2\r\n<\/pre>\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<pre>\r\n<?php get_archives('postbypost', 10); ?> (\u663e\u793a10\u7bc7\u6700\u65b0\u66f4\u65b0\u6587\u7ae0)\r\n<\/pre>\n<p>\u6216\u8005<\/p>\n<pre>\r\n<?php wp_get_archives('type=postbypost&#038;limit=20&#038;format=custom'); ?>\r\n<\/pre>\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<pre>\r\n<?php\r\n$rand_posts = get_posts('numberposts=10&#038;orderby=rand');\r\nforeach( $rand_posts as $post ) :\r\n?>\r\n<!\u2013\u4e0b\u9762\u662f\u4f60\u60f3\u81ea\u5b9a\u4e49\u7684Loop\u2013>\r\n<li><a href=\"<?php the_permalink(); ?>\"><?php the_title(); ?><\/a><\/li>\r\n<?php endforeach; ?>\r\n<\/pre>\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<pre>\r\n<?php\r\nglobal $wpdb;\r\n$sql = \"\r\nSELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,30) AS com_excerpt \r\nFROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID)\r\nWHERE comment_approved = '1' AND comment_type = '' AND post_password = '' \r\nORDER BY comment_date_gmt DESC\r\nLIMIT 10\";\r\n$comments = $wpdb->get_results($sql);\r\n$output = $pre_HTML;\r\nforeach ($comments as $comment)\r\n{\r\n\t$output .= \"\\n<li>\".strip_tags($comment->comment_author).\":\" . \" <a href=\\\"\" . get_permalink($comment->ID) . \"#comment-\" . $comment->comment_ID . \"\\\" title=\\\"on \" . $comment->post_title . \"\\\">\" . strip_tags($comment->com_excerpt) .\"<\/a><\/li>\";\r\n}\r\n$output .= $post_HTML;\r\necho $output;\r\n?>\r\n<\/pre>\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<pre>\r\n<?php\r\n$tags = wp_get_post_tags($post->ID);\r\nif ($tags)\r\n{\r\n\t$first_tag = $tags[0]->term_id;\r\n\t$args = array(\r\n\t\t'tag__in' => array($first_tag),\r\n\t\t'post__not_in' => array($post->ID),\r\n\t\t'showposts'=>10,\r\n\t\t'caller_get_posts'=>1\r\n\t);\r\n\t$my_query = new WP_Query($args);\r\n\tif( $my_query->have_posts() )\r\n\t{\r\n\t\twhile ($my_query->have_posts()) : $my_query->the_post(); ?>\r\n\t\t<li><a href=\"<?php the_permalink() ?>\" rel=\"bookmark\" title=\"<?php the_title_attribute(); ?>\"><?php the_title();?> <?php comments_number(' ','(1)','(%)'); ?><\/a><\/li>\r\n\t\t<?php\r\n\t\tendwhile;\r\n\t}\r\n}\r\nwp_reset_query();\r\n?>\r\n<\/pre>\n<p>5.wordpress\u8c03\u7528\u6307\u5b9a\u5206\u7c7b\u7684\u6587\u7ae0<\/p>\n<pre>\r\n<?php $posts = get_posts( \"category=4&#038;numberposts=10\" ); ?>\r\n<?php if( $posts ) : ?>\r\n<ul>\r\n<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>\r\n  <li>\r\n    <a href=\"<?php the_permalink() ?>\" rel=\"bookmark\" title=\"<?php the_title(); ?>\"><?php the_title(); ?><\/a>\r\n  <\/li>\r\n<?php endforeach; ?>\r\n<\/ul>\r\n<?php endif; ?>\r\n<\/pre>\n<p>6.wordpress\u53bb\u8bc4\u8bba\u8005\u94fe\u63a5\u7684\u8bc4\u8bba\u8f93\u51fa<\/p>\n<pre>\r\n<?php\r\nglobal $wpdb;\r\n$sql = \"\r\nSELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,14) AS com_excerpt \r\nFROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =$wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' \r\nORDER BY comment_date_gmt DESC \r\nLIMIT 10\";\r\n\r\n$comments = $wpdb->get_results($sql);\r\n$output = $pre_HTML;\r\n\r\nforeach ($comments as $comment)\r\n{\r\n\t$output .= \"\\n<li>\".strip_tags($comment->comment_author).\":\" . \" <a href=\\\"\" . get_permalink($comment->ID) . \"#comment-\" . $comment->comment_ID . \"\\\" title=\\\"on \" . $comment->post_title . \"\\\">\" . strip_tags($comment->com_excerpt) .\"<\/a><\/li>\";\r\n}\r\n\r\n$output .= $post_HTML;\r\n\r\necho $output;?>\r\n<\/pre>\n<p>7.wordpress\u8c03\u7528\u542bgravatar\u5934\u50cf\u7684\u8bc4\u8bba\u8f93\u51fa<\/p>\n<pre>\r\n<?php\r\n\r\nglobal $wpdb;\r\n\r\n$sql = \"\r\nSELECT 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 \r\nFROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND comment_author != 'XX' AND post_password = '' \r\nORDER BY comment_date_gmt DESC \r\nLIMIT 10\";\r\n$comments = $wpdb->get_results($sql);\r\n$output = $pre_HTML;\r\n\r\nforeach ($comments as $comment)\r\n{\r\n\t$output .= \"\\n<li>\".get_avatar(get_comment_author_email('comment_author_email'), 18). \" <a href=\\\"\" . get_permalink($comment->ID) . \"#comment-\" . $comment->comment_ID . \"\\\" title=\\\"\" . $comment->post_title . \" \u4e0a\u7684\u8bc4\u8bba\\\">\". strip_tags($comment->comment_author) .\"\uff1a \". strip_tags($comment->com_excerpt) .\"<\/a><\/li>\";\r\n}\r\n\r\n$output .= $post_HTML;\r\n$output = convert_smilies($output);\r\necho $output;\r\n?>\r\n<\/pre>\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<pre>\r\n<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?>\r\n<\/pre>\n<p>2\u3001\u8349\u7a3f\u6570\u76ee\uff1a<\/p>\n<pre>\r\n<?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts->draft; ?>\r\n<\/pre>\n<p>3\u3001\u8bc4\u8bba\u603b\u6570\uff1a<\/p>\n<pre>\r\n<?php echo $wpdb->get_var(\"SELECT COUNT(*) FROM $wpdb->comments\");?>\r\n<\/pre>\n<p>4\u3001\u6210\u7acb\u65f6\u95f4\uff1a<\/p>\n<pre>\r\n<?php echo floor((time()-strtotime(\"2008-8-18\"))\/86400); ?>\r\n<\/pre>\n<p>5\u3001\u6807\u7b7e\u603b\u6570\uff1a<\/p>\n<pre>\r\n<?php echo $count_tags = wp_count_terms('post_tag'); ?>\r\n<\/pre>\n<p>6\u3001\u9875\u9762\u603b\u6570\uff1a<\/p>\n<pre>\r\n<?php $count_pages = wp_count_posts('page'); echo $page_posts = $count_pages->publish; ?>\r\n<\/pre>\n<p>7\u3001\u5206\u7c7b\u603b\u6570\uff1a<\/p>\n<pre>\r\n<?php echo $count_categories = wp_count_terms('category'); ?>\r\n<\/pre>\n<p>8\u3001\u94fe\u63a5\u603b\u6570\uff1a<\/p>\n<pre>\r\n<?php $link = $wpdb->get_var(\"SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'\"); echo $link; ?>\r\n<\/pre>\n<p>9\u3001\u7528\u6237\u603b\u6570\uff1a<\/p>\n<pre>\r\n<?php $users = $wpdb->get_var(\"SELECT COUNT(ID) FROM $wpdb->users\"); echo $users; ?>\r\n<\/pre>\n<p>10\u3001\u6700\u540e\u66f4\u65b0\uff1a<\/p>\n<pre>\r\n<?php $last = $wpdb->get_results(\"SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')\");$last = date('Y-n-j', strtotime($last[0]->MAX_m));echo $last; ?>\r\n<\/pre>\n<p>9.wordpress\u5224\u65ad\u8bed\u53e5<\/p>\n<pre>\r\n<?php is_single()?>\r\n<\/pre>\n<p>\u5224\u65ad\u662f\u5426\u662f\u5177\u4f53\u6587\u7ae0\u7684\u9875\u9762<\/p>\n<pre>\r\n<?php is_single('2')?>\r\n<\/pre>\n<p>\u5224\u65ad\u662f\u5426\u662f\u5177\u4f53\u6587\u7ae0\uff08id=2\uff09\u7684\u9875\u9762<\/p>\n<pre>\r\n<?php is_single('Beef Stew')?>\r\n<\/pre>\n<p>\u5224\u65ad\u662f\u5426\u662f\u5177\u4f53\u6587\u7ae0\uff08\u6807\u9898\u5224\u65ad\uff09\u7684\u9875\u9762<\/p>\n<pre>\r\n<?php is_single('beef-stew')?>\r\n<\/pre>\n<p>\u5224\u65ad\u662f\u5426\u662f\u5177\u4f53\u6587\u7ae0\uff08slug\u5224\u65ad\uff09\u7684\u9875\u9762<\/p>\n<pre>\r\n<?php comments_open()?>\r\n<\/pre>\n<p>\u662f\u5426\u7559\u8a00\u5f00\u542f<\/p>\n<pre>\r\n<?php pings_open()?>\r\n<\/pre>\n<p>\u662f\u5426\u5f00\u542fping<\/p>\n<pre>\r\n<?php is_page()?>\r\n<\/pre>\n<p>\u662f\u5426\u662f\u9875\u9762<\/p>\n<pre>\r\n<?php is_page('42')?>\r\n<\/pre>\n<p>id\u5224\u65ad\uff0c\u5373\u662f\u5426\u662fid\u4e3a42\u7684\u9875\u9762<\/p>\n<pre>\r\n<?php is_page('About Me')?>\r\n<\/pre>\n<p>\u5224\u65ad\u6807\u9898<\/p>\n<pre>\r\n<?php is_page('about-me')?>\r\n<\/pre>\n<p>slug\u5224\u65ad<\/p>\n<pre>\r\n<?php is_category()?>\r\n<\/pre>\n<p>\u662f\u5426\u662f\u5206\u7c7b<\/p>\n<pre>\r\n<?php is_category('6')?>\r\n<\/pre>\n<p>id\u5224\u65ad\uff0c\u5373\u662f\u5426\u662fid\u4e3a6\u7684\u5206\u7c7b<\/p>\n<pre>\r\n<?php is_category('Cheeses')?>\r\n<\/pre>\n<p>\u5206\u7c7btitle\u5224\u65ad<\/p>\n<pre>\r\n<?php is_category('cheeses')?>\r\n<\/pre>\n<p>\u5206\u7c7b slug\u5224\u65ad<\/p>\n<pre>\r\n<?php in_category('5')?>\r\n<\/pre>\n<p>\u5224\u65ad\u5f53\u524d\u7684\u6587\u7ae0\u662f\u5426\u5c5e\u4e8e\u5206\u7c7b5<\/p>\n<pre>\r\n<?php is_author()?>\r\n<\/pre>\n<p>\u5c06\u6240\u6709\u7684\u4f5c\u8005\u7684\u9875\u9762\u663e\u793a\u51fa\u6765<\/p>\n<pre>\r\n<?php is_author('1337')?>\r\n<\/pre>\n<p>\u663e\u793aauthor number\u4e3a1337\u7684\u9875\u9762<\/p>\n<pre>\r\n<?php is_author('Elite Hacker')?>\r\n<\/pre>\n<p>\u901a\u8fc7\u6635\u79f0\u6765\u663e\u793a\u5f53\u524d\u4f5c\u8005\u7684\u9875\u9762<\/p>\n<pre>\r\n<?php is_author('elite-hacker')?>\r\n<\/pre>\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<pre>\r\n<?php is_date()?>\r\n\r\n<?php is_year()?>\r\n\r\n<?php is_month()?>\r\n\r\n<?php is_day()?>\r\n\r\n<?php is_time()?>\r\n<\/pre>\n<p>\u5224\u65ad\u5f53\u524d\u662f\u5426\u662f\u5f52\u6863\u9875\u9762<\/p>\n<pre>\r\n<?php is_archive()?>\r\n<\/pre>\n<p>\u5224\u65ad\u662f\u5426\u662f\u641c\u7d22<\/p>\n<pre>\r\n<?php is_search()?>\r\n<\/pre>\n<p>\u5224\u65ad\u9875\u9762\u662f\u5426404<\/p>\n<pre>\r\n<?php is_404()?>\r\n<\/pre>\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<pre>\r\n<?php if(is_single()):?>\r\n\/\/\u8fd9\u91cc\u5199\u4f60\u60f3\u663e\u793a\u7684\u5185\u5bb9\uff0c\u5305\u62ec\u51fd\u6570\r\n<?php endif;?>\r\n<\/pre>\n<p>\u6216\u8005\uff1a<\/p>\n<pre>\r\n<?php if(is_home() &#038;&#038; !is_paged() ):?>\r\n\/\/\u8fd9\u91cc\u5199\u4f60\u60f3\u663e\u793a\u7684\u5185\u5bb9\uff0c\u5305\u62ec\u51fd\u6570\r\n<?php endif;?>\r\n<\/pre>\n<p>10.wordpress \u975e\u63d2\u4ef6\u8c03\u7528\u8bc4\u8bba\u8868\u60c5<\/p>\n<pre>\r\n<!\u2013smilies\u2013>\r\n<?php\r\nfunction wp_smilies()\r\n{\r\n\tglobal $wpsmiliestrans;\r\n\tif ( !get_option('use_smilies') or (empty($wpsmiliestrans))) return;\r\n\t\r\n\t$smilies = array_unique($wpsmiliestrans);\r\n\t$link='';\r\n\t\r\n\tforeach ($smilies as $key => $smile)\r\n\t{\r\n\t\t$file = get_bloginfo('wpurl').'\/wp-includes\/images\/smilies\/'.$smile;\r\n\t\t$value = \" \".$key.\" \";\r\n\t\t$img = \"<img title=\"WordPress \u51fd\u6570\u8c03\u7528\u5927\u5168 - \u7b2c1\u5f20  | \u6211\u7684\u535a\u5ba2 - \u6280\u672f\u5206\u4eab\" alt=\"WordPress \u51fd\u6570\u8c03\u7528\u5927\u5168 - \u7b2c1\u5f20  | \u6211\u7684\u535a\u5ba2 - \u6280\u672f\u5206\u4eab\" src=\\\"{$file}\\\" alt=\\\"{$smile}\\\" \/>\";\r\n\t\t$imglink = htmlspecialchars($img);\r\n\t\t$link .= \"<a href=\\\"#commentform\\\" title=\\\"{$smile}\\\" onclick=\\\"document.getElementById('comment').value += '{$value}'\\\">{$img}<\/a>&nbsp;\";\r\n\t}\r\n\t\r\n\techo '<div>'.$link.'<\/div>';\r\n}\r\n?>\r\n\r\n<?php wp_smilies();?>\r\n\r\n<!\u2013smilies\u2014>\r\n<\/pre>\n<p>\u5c06\u4ee5\u4e0a\u4ee3\u7801\u590d\u5236\u5230 comments.php \u4e2d\u5408\u9002\u7684\u4f4d\u7f6e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u6a21\u677f\u57fa\u672c\u6587\u4ef6 style.css \u6837\u5f0f\u8868\u6587\u4ef6 index.ph &hellip; <a href=\"https:\/\/www.cnmiss.cn\/?p=361\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-361","post","type-post","status-publish","format-standard","hentry","category-xxbj"],"_links":{"self":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts\/361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=361"}],"version-history":[{"count":0,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts\/361\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}