Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#16626 closed defect (bug) (fixed)

CPT archive rewrite rule doesn't respect 'with_front' arg

Reported by: scribu's profile scribu Owned by: scribu's profile scribu
Milestone: 3.1.1 Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: has-patch commit
Focuses: Cc:

Description (last modified by scribu)

  1. Have WP MS activated, with subdirectories, not subdomains.
  1. Register a custom post type, with has_archive => true.
  1. On the main blog, call get_post_archive_link().

The URL will include the /blog/ prefix, but it will lead to a 404, since the rewrite rule isn't correct.

Attachments (2)

16626.diff (796 bytes) - added by scribu 14 years ago.
test-16626.php (389 bytes) - added by scribu 14 years ago.
Clearer

Download all attachments as: .zip

Change History (14)

#1 @scribu
14 years ago

  • Description modified (diff)
  • Summary changed from get_post_archive_link() includes /blog/, when it shouldn't to CPT archive rewrite rule doesn't respect 'with_front' arg

@scribu
14 years ago

#2 @scribu
14 years ago

  • Keywords has-patch added

The trouble comes from the fact that $wp_rewrite->add_rule() is used directly, which doesn't have a $with_front argument.

See 16626.diff.

Last edited 14 years ago by scribu (previous) (diff)

#3 @rfair404
14 years ago

Seems that 16626.diff does work. When I previously rec'd a 404 not found error when trying to load a single custom post type. When I used your diff, I am now able to see the post. still uses the /blog url structure, which is another issue though.

Last edited 14 years ago by rfair404 (previous) (diff)

#4 @scribu
14 years ago

still uses the /blog url structure, which is another issue though.

Yes, that's the idea. If you don't want to use /blog, just say so:

register_post_type( ..., array(
  'rewrite' => array( 'with_front' => false ),
  ...
) );
Last edited 14 years ago by scribu (previous) (diff)

#5 @rfair404
14 years ago

seems that using 16626.diff caused this error though.

Fatal error: Cannot redeclare class Walker_Page in /.../wp-includes/post-template.php on line 1062

#6 @scribu
14 years ago

Are you sure that's not caused by a plugin or theme?

#7 @nacin
14 years ago

Walker_Page was moved from wp-includes/classes.php (and that file was killed) to wp-includes/post-template.php. I would make sure your upgrade was complete.

@scribu
14 years ago

Clearer

#8 @scribu
14 years ago

  • Owner set to scribu
  • Status changed from new to reviewing

Follow-up: #16725

#9 @scribu
14 years ago

  • Keywords commit added

#10 @azizur
14 years ago

  • Cc azizur added

#11 @markjaquith
14 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

(In [17514]) Use with_front properly when creating rules for CPT archive pages. props scribu. fixes #16626 for trunk

#12 @markjaquith
14 years ago

(In [17515]) Use with_front properly when creating rules for CPT archive pages. props scribu. fixes #16626 for 3.1

Note: See TracTickets for help on using tickets.