WordPress的如何创建自定义发布模板

问题描述:

WordPress的如何从部分INDEX.php创建自定义发布模板!在我的Frontpage(Index.php)上我有很棒的邮政网格。我希望这个网格也在每个帖子(在评论字段之间的帖子内容)下。我从(Index.php)代码复制了一些部分并插入到post.php中,但结果并不令人满意。WordPress的如何创建自定义发布模板

我到处搜索,但无法找到令人满意的解决方案,这与我的wordpress主题兼容。如果有人能帮助我,请告诉我你需要什么代码。我会非常乐意听到解决方案!

由于提前

+0

在评论栏之间的帖子内容下,混淆你的问题,解释一点点清楚。 – GNANA

不是很清楚你的意思,但我想你想打印一些职位对你的single.php文件。为了实现这一点,你需要一个WP_Query类似于:

<?php 
// the query 
$args = array(
    'post_type' => 'post' // change as needed 
); 
$the_query = new WP_Query($args); ?> 

<?php if ($the_query->have_posts()) : ?> 

<!-- the loop --> 
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?> 
    <h2><?php the_title(); ?></h2> <!-- Copy same structure and data as the one on the index.php file --> 
<?php endwhile; ?> 
<!-- end of the loop --> 

<?php wp_reset_postdata(); ?> 

您将需要保持同一div结构和类是对的index.php一个让他们看起来很像。 祝你好运!