WordPress编辑php get_template_part()和get_post_format()函数

时间:2012-06-04 22:13:15

标签: php wordpress

我想加载帖子内容,但没有标题,日期,评论等信息。有没有办法只抓住这个帖子?

<?php if ( have_posts() ) : ?>
   <?php while ( have_posts() ) : the_post(); ?>
   <?php get_template_part( 'content', get_post_format() ); ?>
   <?php endwhile; ?>
<?php endif; ?>

2 个答案:

答案 0 :(得分:8)

您可以替换

 <?php get_template_part( 'content', get_post_format() ); ?>

 <?php get_template_part( 'content', 'myformat' ); ?> 

并修改名为content-page.php的{​​{1}}副本,您可以在其中删除content-myformat.php行。

答案 1 :(得分:7)

简单地替换:

    <?php get_template_part( 'content', get_post_format() ); ?>

使用:

    <?php the_content(); ?>

前者正在寻找类似 content-status.php content-aside.php 的内容,或者最有可能的是,如果是普通的“帖子”,主题根目录中的 content.php

相关问题