【发布时间】:2021-08-05 12:57:40
【问题描述】:
我想将博客设置为主页。我用下面的代码创建了一个front-page.php。
代码将最近的帖子显示为主页。我想使用 1 个特定博客作为主页,而不是最近的博客或置顶帖子。
这是示例网站。博客用作主页。如果发布了新博客,主页不会更改。
https://height-comparison.com/
原帖: How to make Wordpress show only one post on the front page with comments, and comment form?
<?php get_header(); ?>
<div class="blog">
<section>
<div class="container">
<div class="row">
<div class="blog-sidebar">
<?php get_sidebar(); ?>
</div>
<div class="span8">
<?php $articles = new WP_Query(array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1
));?>
<?php while ($articles->have_posts()): $articles->the_post(); ?>
<article id="post-<?php the_ID(); ?>" role="article">
<header>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'wpbs-featured' ); ?></a>
<section class="post_content clearfix" >
<?php the_content(); ?>
</section>
</article>
<?php endwhile; ?>
<?php comments_template('',true); ?>
</div>
</div>
</div>
</section>
</div>
<?php get_footer(); ?>
提前谢谢你。
【问题讨论】:
-
根本不清楚你在问什么。请参阅How to Ask 并接听tour。
标签: wordpress blogs website-homepage