WordPress.org

Make WordPress Core

Changeset 7204


Ignore:
Timestamp:
03/10/2008 07:15:01 AM (10 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/link-template.php

    r7022 r7204  
    8181            if ( $parent=$cats[0]->parent )
    8282                $category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
     83        }
     84
     85        // show default category in permalinks, without
     86        // having to assign it explicitly
     87        if ( empty($category) ) {
     88            $default_category = get_category( get_option( 'default_category' ) );
     89            $category = is_wp_error( $default_category)? '' : $default_category->slug;
    8390        }
    8491
Note: See TracChangeset for help on using the changeset viewer.