Php 使用wordpress在下划线.me上创建博客模板页面
我正在尝试个性化一个用下划线.me创建的新主题,但我似乎无法创建一个新的模板页面,其中包含一个循环,可以显示一个特定类别的帖子,我该怎么做 我将在这里粘贴underline.me主题的index.php,witch有一个通用循环,遗憾的是,在模板页面上复制和粘贴这个循环就可以了Php 使用wordpress在下划线.me上创建博客模板页面,php,wordpress,Php,Wordpress,我正在尝试个性化一个用下划线.me创建的新主题,但我似乎无法创建一个新的模板页面,其中包含一个循环,可以显示一个特定类别的帖子,我该怎么做 我将在这里粘贴underline.me主题的index.php,witch有一个通用循环,遗憾的是,在模板页面上复制和粘贴这个循环就可以了 <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> &l
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php if ( is_home() && ! is_front_page() ) : ?>
<header>
<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
</header>
<?php endif; ?>
<?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( 'template-parts/content', get_post_format() );
?>
<?php endwhile; ?>
<?php the_posts_navigation(); ?>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
这是page.php
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'template-parts/content', 'page' ); ?>
<?php
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
?>
<?php endwhile; // End of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
好消息是,对于特定的类别,您不需要特定的循环。 如果您的主题中有一个category.php文件,并假设您的类别名称为“Lux Cars”,id为“35”。如果您将category.php复制为category-35.php或category-lux-cars.php(类别的slug)。当您打开此类别的帖子时。wordpress调用此文件并在该循环中显示帖子。您可以编辑category-35.php并添加任何类别详细信息或其他内容 但是,如果您仍然需要特定类别的循环,那么您可以使用该代码
//这里的风格帖子