Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#13068 closed feature request (wontfix)

Custom filters and actions for post_types rewrite urls

Reported by: butuzov's profile butuzov Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Posts, Post Types Keywords: needs-patch close
Focuses: Cc:



Can developers get a filter for {$args->rewriteslug?}/%$post_type% ?
and few do actions after?

let me be clear.

we (developers) can't change this rewrite's for custom needs, and we can't add after that custom variables.

here is code that we have now.

if ( $args->hierarchical )
	$wp_rewrite->add_rewrite_tag("%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
	$wp_rewrite->add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
$wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front'], $args->permalink_epmask);

its can be replaces by the code

something like this

	$args->hierarchical ? '(.+?)' : '([^/]+)', 
	$args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
	apply_filters("rewrite_base_custom_{$post_type}", "{$args->rewrite['slug']}/%$post_type%"), 


Change History (7)

#1 @butuzov
14 years ago

Forgot to tell
this is a wp-includes/post.php
function register_post_type

#2 @dd32
14 years ago

As a plugin author, you may set rewrite to false for the post_type registration, and call $wp_rewrite->add_rewrite_tag() / $wp_rewrite->add_permastruct() with as many complex structures as you wish.

IMO, The permalink support included in core should be as basic as possible, for this release at least. More complex permalink support (such as whats provided for posts) could be possible in a future release..

My suggestion is, that this be closed as wontfix, due to the much more powerful options being available...

#3 @butuzov
14 years ago

Hi dd32.

I am not talking about add_permastruct, i working with custom post types right now, and inside register_post_type no any posible way to implrove it. This is a new feature and its can be better, so why not add a simple way in WP ideology to improve new features?

i havn't take a look to taxonomies. but i think there is can be few more improvements.

#4 @dd32
14 years ago

  • Keywords needs-patch added
  • Milestone changed from 3.0 to 3.1

I am not talking about add_permastruct, i working with custom post types right now

My point was, register_post_type() makes a BASIC and GENERIC add_permastruct() / add_Rewrite_tag() rewrite rule for your post_type.

Your plugin still needs to flush the rewrite rules on activation / adding of the post_type. At this stage, If the basic rewrite rules are not powerful enough for your purpose, you'll need to add a rewrite rules yourself to achieve it.

I'm moving this to 3.1 as 3.0 will have nothing other than a bare basics of URL routing for custom post_types.

#5 @nacin
14 years ago

  • Keywords close added
  • Milestone changed from 3.1 to Future Release

#6 @mikeschinkel
14 years ago

  • Cc mikeschinkel@… added

#7 @scribu
13 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

+1 on setting 'rewrite' => false and defining rewrite rules yourself.

register_post_type() has too many arguments as it is.

Note: See TracTickets for help on using tickets.