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

acc*_*man 4 php wordpress

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

<?php if ( have_posts() ) : ?>
   <?php while ( have_posts() ) : the_post(); ?>
   <?php get_template_part( 'content', get_post_format() ); ?>
   <?php endwhile; ?>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

小智 8

你可以替换

 <?php get_template_part( 'content', get_post_format() ); ?>
Run Code Online (Sandbox Code Playgroud)

 <?php get_template_part( 'content', 'myformat' ); ?> 
Run Code Online (Sandbox Code Playgroud)

并编辑content-page.php带有名称的副本content-myformat.php,您可以在其中删除the_title()行.


Fox*_*nni 7

简单地替换:

    <?php get_template_part( 'content', get_post_format() ); ?>
Run Code Online (Sandbox Code Playgroud)

附:

    <?php the_content(); ?>
Run Code Online (Sandbox Code Playgroud)

前者正在寻找类似content-status.phpcontent-aside.php的内容,或者很可能是在主题根目录中使用简单的旧帖子" content.php".