这里要使用require来调用其他文件。
在wordpress里,有很方便的函数来调用文件,
比如 get_template_part ,get_header , get_fooer , get_sidebar等
下面一一讲解:
我以前是设置常量MBDIR,现在不用了,可以用 get_template_part
如分类页面category.php
可以用 <?php get_template_part( 'display/grid', 'none' ); ?> --- 会调用 display/grid.php
<?php get_template_part( 'display/grid', 'img' ); ?> --- 会调用 display/grid-img.php 或display/grid.php
-------------------
Using loop.php in child themes
Assuming the theme folder is wp-content/themes, that the parent theme is twentyten, and the child theme is twentytenchild, then the following code:
<?php get_template_part( 'loop', 'index' ); ?> 会是怎么样的?
执行顺序如下:
wp-content/themes/twentytenchild/loop-index.php
wp-content/themes/twentyten/loop-index.php
wp-content/themes/twentytenchild/loop.php --- 后面的index也可以没有。
wp-content/themes/twentyten/loop.php
---------------------------
https://developer.wordpress.org/reference/functions/get_template_part/
get_template_part位于 wp-includes 下的 general-template.php
--------------------------
和网站头部内容 get_header() 来调用文件。--- 底部文件一样的。
-------------
329




被折叠的 条评论
为什么被折叠?



