Make WordPress Core

Opened 19 months ago

Closed 7 months ago

#62135 closed defect (bug) (worksforme)

Custom Post Type feed rewrites not generated when has_archive is false

Reported by: sippis's profile sippis Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Posts, Post Types Keywords: reporter-feedback close
Focuses: Cc:

Description

I have a Custom Post Type called movies. In the registration, I've set has_archive to false but rewrite.feeds to true.

The [documentation of parameters](https://developer.wordpress.org/reference/functions/register_post_type/#parameters) leads me to believe that this would cause feed rewrites being generated in /movies/feed although I don't have archive at /movies.

feeds bool
Whether the feed permastruct should be built for this post type.
Default is value of $has_archive.

That is not what happens. The feed permastruct is not built unless has_archive is true. See https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/class-wp-post-type.php#L712-L725

Change History (2)

#1 @SirLouen
8 months ago

  • Keywords reporter-feedback close added

Reproduction Report

Description

❌ This report can't validates that the issue can be reproduced.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.29
  • Server: nginx/1.29.1
  • Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
  • Browser: Firefox 141.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Testing Dolly
    • Test Reports 1.2.0

Testing Instructions

  1. Create a the new CPT movies using the code template in Supplemental Artifats
  2. Set Settings > Permalinks to Post Names
  3. Go to <url>/movies/feed/
  4. 👌 The XML feed is downloaded successfully.

Actual Results

  1. ❌ Error condition is not occurring

Additional Notes

  • @sippis can you check the code provided, here we are using as you say has_archive to false while using rewrite.feeds to true and the feed can be accessed without troubles.
  • I'm going to set this as close as it cannot be reproduced for now while the reporter could inform in case he can provide more information for reproduction purposes.

Supplemental Artifacts

Sample code:

add_action( 'init', function() {
	register_post_type( 'movies', [
		'label' => 'Movies',
		'public' => true,
		'has_archive' => false,
		'rewrite' => array(
			'feeds' => true,
		),
		'supports' => [
			'title',
			'editor',
		],
	] );
} );

#2 @SirLouen
7 months ago

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

Given that one month has passed and no answer by the reporter, I think it's a good time to close this as worksforme.

@sippis feel free to comment back if you have any information to add for reproduction and testing, and I will be happy to get back to this ticket and help move it forward.

Note: See TracTickets for help on using tickets.