一个Wordpress主题,包括以下几个文件:
1、style.css(必须包括,申明主题名)
2、index.php(必须包括,否则报错)
3、functions.php(内容可以为空,确切的说,也可以删除)
4、screenshot.png(确切的说,也可以删除)
添加一个这样的最小主题,我们看看显示的情况:
前台显示空。
如果添加一条html语句,如<p>测试</p>,显示前台代码也只是包括<p>测试</p> 这么一条HTML语句。
二、如果添加一下函数:
get_header();
get_search_form();
get_sidebar();
get_footer();
都可以添加程序默认的页头、页脚,搜索框和边栏。
查看HTML源代码,带了各种格式,并自动导入了一些CSS。
如下:
(这篇文章的作用到此为止,存在这里为以后增加功能时对比 :)
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN"> <head> <link rel="profile" href="http://gmpg.org/xfn/11" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>wordpress – 又一个WordPress站点</title> <link rel="stylesheet" href="http://127.0.0.1/wordpress/wp-content/themes/jijianzhuti/style.css" type="text/css" media="screen" /> <link rel="pingback" href="http://127.0.0.1/wordpress/xmlrpc.php" /> <link rel='dns-prefetch' href='//s.w.org' /> <script type="text/javascript"> window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/11\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/11\/svg\/","svgExt":".svg","source":{"concatemoji":"http:\/\/127.0.0.1\/wordpress\/wp-includes\/js\/wp-emoji-release.min.js?ver=5.0.1"}}; !function(a,b,c){function d(a,b){var c=String.fromCharCode;l.clearRect(0,0,k.width,k.height),l.fillText(c.apply(this,a),0,0);var d=k.toDataURL();l.clearRect(0,0,k.width,k.height),l.fillText(c.apply(this,b),0,0);var e=k.toDataURL();return d===e}function e(a){var b;if(!l||!l.fillText)return!1;switch(l.textBaseline="top",l.font="600 32px Arial",a){case"flag":return!(b=d([55356,56826,55356,56819],[55356,56826,8203,55356,56819]))&&(b=d([55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447],[55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447]),!b);case"emoji":return b=d([55358,56760,9792,65039],[55358,56760,8203,9792,65039]),!b}return!1}function f(a){var c=b.createElement("script");c.src=a,c.defer=c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var g,h,i,j,k=b.createElement("canvas"),l=k.getContext&&k.getContext("2d");for(j=Array("flag","emoji"),c.supports={everything:!0,everythingExceptFlag:!0},i=0;i<j.length;i++)c.supports[j[i]]=e(j[i]),c.supports.everything=c.supports.everything&&c.supports[j[i]],"flag"!==j[i]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[j[i]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(h=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",h,!1),a.addEventListener("load",h,!1)):(a.attachEvent("onload",h),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),g=c.source||{},g.concatemoji?f(g.concatemoji):g.wpemoji&&g.twemoji&&(f(g.twemoji),f(g.wpemoji)))}(window,document,window._wpemojiSettings); </script> <style type="text/css"> img.wp-smiley, img.emoji { display: inline !important; border: none !important; box-shadow: none !important; height: 1em !important; width: 1em !important; margin: 0 .07em !important; vertical-align: -0.1em !important; background: none !important; padding: 0 !important; } </style> <link rel='stylesheet' id='wp-block-library-css' href='http://127.0.0.1/wordpress/wp-includes/css/dist/block-library/style.min.css?ver=5.0.1' type='text/css' media='all' /> <link rel='https://api.w.org/' href='http://127.0.0.1/wordpress/index.php?rest_route=/' /> <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://127.0.0.1/wordpress/xmlrpc.php?rsd" /> <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://127.0.0.1/wordpress/wp-includes/wlwmanifest.xml" /> <meta name="generator" content="WordPress 5.0.1" /> <link rel="canonical" href="http://127.0.0.1/wordpress/" /> <link rel='shortlink' href='http://127.0.0.1/wordpress/' /> <link rel="alternate" type="application/json+oembed" href="http://127.0.0.1/wordpress/index.php?rest_route=%2Foembed%2F1.0%2Fembed&url=http%3A%2F%2F127.0.0.1%2Fwordpress%2F" /> <link rel="alternate" type="text/xml+oembed" href="http://127.0.0.1/wordpress/index.php?rest_route=%2Foembed%2F1.0%2Fembed&url=http%3A%2F%2F127.0.0.1%2Fwordpress%2F&format=xml" /> <link rel="icon" href="http://127.0.0.1/wordpress/wp-content/uploads/2019/01/cropped-post_loading-32x32.gif" sizes="32x32" /> <link rel="icon" href="http://127.0.0.1/wordpress/wp-content/uploads/2019/01/cropped-post_loading-192x192.gif" sizes="192x192" /> <link rel="apple-touch-icon-precomposed" href="http://127.0.0.1/wordpress/wp-content/uploads/2019/01/cropped-post_loading-180x180.gif" /> <meta name="msapplication-TileImage" content="http://127.0.0.1/wordpress/wp-content/uploads/2019/01/cropped-post_loading-270x270.gif" /> <style type="text/css" id="wp-custom-css"> * { box-sizing: border-box; } </style> </head> <body class="home page-template-default page page-id-1096"> <div id="page"> <div id="header" role="banner"> <div id="headerimg"> <h1><a href="http://127.0.0.1/wordpress/">wordpress</a></h1> <div class="description">又一个WordPress站点</div> </div> </div> <hr /> <form role="search" method="get" id="searchform" class="searchform" action="http://127.0.0.1/wordpress/"> <div> <label class="screen-reader-text" for="s">搜索:</label> <input type="text" value="" name="s" id="s" /> <input type="submit" id="searchsubmit" value="搜索" /> </div> </form><p>测试</p> <div id="sidebar" role="complementary"> <ul> <li> <form role="search" method="get" id="searchform" class="searchform" action="http://127.0.0.1/wordpress/"> <div> <label class="screen-reader-text" for="s">搜索:</label> <input type="text" value="" name="s" id="s" /> <input type="submit" id="searchsubmit" value="搜索" /> </div> </form> </li> <!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it. <li><h2>作者</h2> <p>A little something about you, the author. Nothing lengthy, just an overview.</p> </li> --> </ul> <ul role="navigation"> <li class="pagenav"><h2>页面</h2><ul><li class="page_item page-item-13"><a href="http://127.0.0.1/wordpress/?page_id=13">FAQ</a></li> <li class="page_item page-item-12"><a href="http://127.0.0.1/wordpress/?page_id=12">Features</a></li> <li class="page_item page-item-14"><a href="http://127.0.0.1/wordpress/?page_id=14">Shortcodes</a></li> <li class="page_item page-item-15"><a href="http://127.0.0.1/wordpress/?page_id=15">Submit A Ticket</a></li> <li class="page_item page-item-96"><a href="http://127.0.0.1/wordpress/?page_id=96">测试</a></li> <li class="page_item page-item-1107"><a href="http://127.0.0.1/wordpress/?page_id=1107">测试页面-特色图片</a></li> <li class="page_item page-item-1096 current_page_item"><a href="http://127.0.0.1/wordpress/">测试页面1</a></li> <li class="page_item page-item-1098"><a href="http://127.0.0.1/wordpress/?page_id=1098">测试页面2</a></li> <li class="page_item page-item-2"><a href="http://127.0.0.1/wordpress/?page_id=2">示例页面</a></li> </ul></li> <li><h2>文章归档</h2> <ul> <li><a href='http://127.0.0.1/wordpress/?m=201901'>2019年一月</a></li> <li><a href='http://127.0.0.1/wordpress/?m=201812'>2018年十二月</a></li> </ul> </li> <li class="categories"><h2>分类目录</h2><ul> <li class="cat-item cat-item-1"><a href="http://127.0.0.1/wordpress/?cat=1" >未分类</a> (6) </li> </ul></li> </ul> <ul> <li><h2>功能</h2> <ul> <li><a href="http://127.0.0.1/wordpress/wp-login.php">登录</a></li> </ul> </li> </ul> </div> <hr /> <div id="footer" role="contentinfo"> <!-- If you'd like to support WordPress, having the "powered by" link somewhere on your blog is the best way; it's our only promotion or advertising. --> <p> wordpress自豪地采用<a href="https://wordpress.org/">WordPress</a>构建 </p> </div> </div> <!-- Gorgeous design by Michael Heilemann - http://binarybonsai.com/kubrick/ --> <script type='text/javascript' src='http://127.0.0.1/wordpress/wp-includes/js/comment-reply.min.js?ver=5.0.1'></script> <script type='text/javascript' src='http://127.0.0.1/wordpress/wp-includes/js/wp-embed.min.js?ver=5.0.1'></script> </body> </html>
比如:
自动增加的CSS:
<link rel="stylesheet" href="http://127.0.0.1/wordpress/wp-content/themes/jijianzhuti/style.css" type="text/css" media="screen" />
所以我们可以知道主题的style.css是可以自动导入的。
[结束]