Make WordPress Core

Opened 17 months ago

Last modified 17 months ago

#57390 new defect (bug)

[ wp-includes/template.php - get_archive_template() ] - archive for post doesn't load the correct template

Reported by: riccardodicurti's profile riccardodicurti Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 1.5
Component: Themes Keywords: needs-patch
Focuses: Cc:

Description

Good morning everyone, while making templates for the post-type 'post' I discovered that:

The get_archive_template() function ( in wp-includes/template.php line 150 ) for a post archive returns archive.php instead of archive-post.php while the get_single_template() function for a post returns single-post.php.

In my opinion, the two results don't agree each other and the first function should work for posts as well.

Thanks in advance.

Change History (2)

#1 @rajinsharwar
17 months ago

The get_archive_template() function retrieves the path to the archive template file for the current query. This function displays a list of posts on an archive page, such as a blog homepage or a category page. The function first checks if only one post type is being queried for, and if so, it tries to find a template specific to that post type. For example, if the post type is 'post', it will try to find a template named 'archive-post.php'. The function returns to the default 'archive.php' template if no such template is found. This behavior is intentional, I believe, and is designed to allow theme developers to create specific templates for different post types if needed. For example, a theme might want to display posts in a different way on the archive page, depending on the post type.

#2 @riccardodicurti
17 months ago

Surely I have expressed myself wrongly, I mean that it doesn't return archive-post.php when you are on a post archive page. Doesn't it return the same thing to you?

Note: See TracTickets for help on using tickets.