Use default category when getting permalink if the post has no categories assigned. Props nbachiyski. see #6083

git-svn-id: http://svn.automattic.com/wordpress/trunk@7204 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-10 07:15:01 +00:00
parent f957f7307d
commit 8aab63b7cf
1 changed files with 7 additions and 0 deletions

View File

@ -82,6 +82,13 @@ function get_permalink($id = 0, $leavename=false) {
$category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
}
// show default category in permalinks, without
// having to assign it explicitly
if ( empty($category) ) {
$default_category = get_category( get_option( 'default_category' ) );
$category = is_wp_error( $default_category)? '' : $default_category->slug;
}
$author = '';
if ( strpos($permalink, '%author%') !== false ) {
$authordata = get_userdata($post->post_author);