Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#39147 closed defect (bug) (invalid)

Single.php and post formats - wrong content

Reported by: gwgw's profile gwgw Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: Post Formats Keywords:
Focuses: Cc:


In my single.php file i'm trying to get content, for specific post format using get_teplate part.

Example, single.php file:

get_template_part( 'template-parts/single-post/content',get_post_format() );

In my template-parts/single-post subfolder i have:
content.php - for standard posts, content-aside.php for aside and so on...
In this files i'm using:

To get content from database...and its not work,
when i use the_excerpt();
i'm getting excerpt from previous post, not the current one.

Now, not-funny thing:
When i delete single.php and use index.php with:
get_template_part( 'template-parts/single-post/content',get_post_format() );
Everything works fine, i get proper content for proper post format,
its like i can't use: get_post_format() inside single.php
Is it bug, or only custom theme problem?

Change History (1)

#1 @johnbillion
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi @gwgw. Welcome to WordPress Trac.

This isn't the place for such support tickets. It may be that your template file is missing a call to the_post(), or a previous loop on the page is using query_posts() and breaking things.

You'd be best off posting on the support forums with some more information, possibly with a link to your complete template file.

Note: See TracTickets for help on using tickets.