Closed arjenlentz closed 13 years ago
did a bit more digging... in /wp-includes/link-template.php function get_permalink(): ... if ( $post->post_type == 'page' ) return get_page_link($post->ID, $leavename, $sample); elseif ( $post->post_type == 'attachment' ) return get_attachment_link($post->ID); elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) return get_post_permalink($post->ID, $leavename, $sample);
so here it appears that the page_type 'page' gets special treatment so you get a page_link rather than a post_permalink. Wondering how to work that system rather than having to hack the core... For most builtin types (post,attachment,etc) the capability_type is 'post', except for page where it's 'page'. For wiki it's currently 'wiki_page' - perhaps it should be 'page' instead - but nevertheless a patch to core would be required.
Right now I'll hack core to make it work for me, but perhaps the above helps find a sane solution for the future...
Perhaps adding a %posttype% in the permalink rewriter could do the trick. but the current code of get_post_permalink still appears odd, particularly the %$post->post_type% bit... seems hardcoded to rewrite /post/ but I tried that so perhaps it uses another code path...
function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { global $wp_rewrite;
$post = &get_post($id);
if ( is_wp_error( $post ) )
return $post;
$post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
$slug = $post->post_name;
$draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
$post_type = get_post_type_object($post->post_type);
if ( !empty($post_link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) {
if ( ! $leavename ) {
if ( $post_type->hierarchical )
$slug = get_page_uri($id);
$post_link = str_replace("%$post->post_type%", $slug, $post_link);
}
$post_link = home_url( user_trailingslashit($post_link) );
} else {
if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) )
$post_link = add_query_arg($post_type->query_var, $slug, '');
else
$post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
$post_link = home_url($post_link);
}
return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}
I have my permalink set to /post/%postname%/ When I now create a new wiki page from dashboard, it becomes /post/wiki/WikiName but when I create a link in a wiki page it's referenced as /wiki/WikiName and thus doesn't work. Of course the latter is what I want (ideally) but somehow creating wiki pages from dashboard doesn't do the right thing...
Horay! From Pedro Padron (@ppadron, www.w3p.com.br) comes this fix:
on line 112 of the wp-wiki.php, just add to the array: 'rewrite'=> array('with_front' => false),
I added this to the commit I'm about to make before you posted here. There have been other permalink issues as well that have all been fixed in WordPress 3.1.
My permalink url for Posts is set to /blog/%postname% so that they steer clear of Pages. Now, while Wiki pages behaves like Pages, they appear to be using the Posts url path, as the calculated new permalink for a Wiki ends up being /blog/wiki/... So that's inconsistent/wrong (and in this case quite undesirable) - had a peek in the code but can't work out where/why this happens - not familiar with the WP infra really.