<?php

 get_header(); ?>

     <div id="primary" class="content-area col-md-9">
<main id="main" class="site-main" role="main"> <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?> <?php
/* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
?> <?php endwhile; ?> <?php blain_pagination(); ?> <?php else : ?> <?php get_template_part( 'no-results', 'index' ); ?> <?php endif; ?> </main><!-- #main -->
</div><!-- #primary --> <?php get_sidebar(); ?>
<?php get_footer(); ?>

以上是一个index.php

中间有几个重要的函数:

get_header()————调用header.php,该函数和下面几个一样是wordpress提供的函数。

get_footer()————调用footer.php

get_sidebar()————调用sidebar.php

get_template_part('a','b')——调用其他文件,如果存在a-b.php文件,将其调用,没有就只调用a.php

index.php的内容大多都是调用,将其他php内容调用组合起来,当然,你要直接在其中写代码也可以。

have_posts() ) : the_post();
循环文章,如果存在,则一章章的读取,每一次读取都会将这个while整个部分循环一遍。这个是用于循环输出文章的标题等简单信息的。
这一段的意思是循环读取文章,每读取了一次,就加载content.php或content-n.php文件(后面的函数用于判断文章类型,除了系统设定的之外,还能在functions.php中添加几个)
而这个content.php就是如何展示文章的文件,是否要缩略图,标题的大小和位置等等都会在这里规定,例如:

这样。当然除了这种类似贴吧的首页之外,也能放其他东西,例如视频什么的,不一定非要调用文章部分内容。

												

最新文章

  1. Eclipse出现&quot;Running Android Lint has encountered a problem&quot;解决方案
  2. 浅谈利用SQLite存储离散瓦片的思路和实现方法
  3. http://note.youdao.com/yws/public/redirect/share?id=2bc2dc6c7df6013e9f8106c005da999a&type=false
  4. MFC的几处坑
  5. C#的值参数与引用参数
  6. Oracle 学习之路开始
  7. 自动备份sqlexpress 数据库脚本
  8. [C语言 - 3] 字符串
  9. Eclipse的设置小细节提高开发效率
  10. 定时器NSTimer的用法
  11. Spring对IOC的理解
  12. js 实现 复制 功能 (zeroclipboard)
  13. SpringCloud应对高并发的思路
  14. 简化kubernetes应用部署工具之Helm应用部署
  15. 使用docker加载已有镜像安装Hyperledger Fabric v1.1.0
  16. Android 利用二次贝塞尔曲线模仿购物车加入物品抛物线动画
  17. NumPy for MATLAB users
  18. 使用Flask+MongoDB实现基于REST的接口简单操作
  19. 【第二十三章】 springboot + 全局异常处理
  20. ZOJ 3869 Ace of Aces

热门文章

  1. [Jmeter]jmeter之参数化
  2. javascript和jquery比较中学习
  3. pgmpy包的安装,以及conda的安装
  4. VMMap(查看内存工具)
  5. Python笔记6(异常)-20160924
  6. checkbox:获取所有已选中的值
  7. python 基础学习4-with语句
  8. jQuery EasyUI的使用入门
  9. linux: 几个常用makefile模板
  10. hihoCoder挑战赛11 A 随机斐波那契