Editing WordPress php get_template_part () and get_post_format ()

I want to download the contents of the message only without a title, date, comment, etc. Is there a way to capture a message only?

<?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php endif; ?> 
+4
source share
2 answers

Just replace:

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

FROM

  <?php the_content(); ?> 

The first one is looking for something like content-status.php or content-aside.php or, most likely, in the case of a simple old post, content.php is at the root of your topic.

+7
source

You can replace

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

from

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

and edit a copy of content-page.php called content-myformat.php , where you can remove the_title() .

+8
source

Source: https://habr.com/ru/post/1416065/


All Articles