问题有点长,但是真心希望有大神能给解答一下,本菜先在这里谢过了!
首先,我在主题的根目录下复制了index.php,并重命名为page.php。然后将其设置为名叫home的模板。随后,我在wordpress面板中新建了一个首页页面,使用的是刚刚的home模板,并将其添加到导航栏中
此时页面显示的是index.php的内容,可是当我点击首页按钮时,页面变成了这样!
为什么会这样呢,首页的效果不是应该和index一样吗?怎么才能让点击首页出现的界面和index一样呢?
再附上index.php的代码。。
<?php get_header(); ?>
<!--mainbody-->
<div class="container">
<div class="row">
<div class="col-md-8">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article class="articles">
<header>
<a href="#" class="cat">散文<i></i></a>
<a href="<?php the_permalink(); ?>" class="gotoArchive"><?php the_title(); ?></a>
</header>
<p class="content"><?php echo mb_strimwidth(get_the_content(), 0, 600,'...'); ?></p>
<footer>
<a href="#">#test</a>
<a href="#">#articels</a>
<a href="#">#something</a>
<span><a href="<?php the_permalink(); ?>" class="content">继续阅读>></a></span>
</footer>
</article>
<?php endwhile; else:?>
<p><?php _e('the page could not found'); ?></p>
<?php endif; ?>
<?php if(function_exists('wp_bs_pagination')){
wp_bs_pagination();
} ?>
</div><!--col-md-8-->
</div><!--row-->
</div><!--container-->
<?php get_footer(); ?>
你可能忘记到管理界面中的 设定 > 阅读页面你建的模板文件设为首页了。
ps.
循环:https://codex.wordpress.org/T...;
模板层次:https://codex.wordpress.org/F...。