From 64aaf796c219b71f5b091623b9898b364970ac6d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 10 Mar 2008 07:15:01 +0000 Subject: [PATCH] Use default category when getting permalink if the post has no categories assigned. Props nbachiyski. see #6083 git-svn-id: https://develop.svn.wordpress.org/trunk@7204 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/link-template.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 3c387d9470..d2bb5a47f7 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -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);