使用Wordpress,你可以创建模板文件。我在查找它如何加载文件时遇到了一些困难。这是因为大多数框架将使用Ob、start等,但wordpress仍然可以访问返回对象的方法。例如:
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( 'template-parts/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
// End of the loop.
endwhile;
?>
</main><!-- .site-main -->
<?php get_sidebar( 'content-bottom' ); ?>
上面的代码片段使用了the_post()和get_side()等方法(或函数)。
Wordpress如何加载模板并提供上述函数的使用?
发布于 2018-08-17 07:48:46
您需要具有特定名称的文件:
template-your_name.php
并添加文件的第一部分:
<php
/*
Template Name: Your template name
*/
之后,您将在模板列表中看到它。
https://stackoverflow.com/questions/51884587
复制相似问题