首页 技术 正文
技术 2022年11月14日
0 收藏 449 点赞 3,590 浏览 1171 个字
 <?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就是如何展示文章的文件,是否要缩略图,标题的大小和位置等等都会在这里规定,例如:

wordpress建站过程4——index.php

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


    					
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,488
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,489
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,290