From 57d2c46591e6593c8d6bfcb2100b6538e80f9dce Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 14 Jun 2016 23:11:33 +0000 Subject: [PATCH] Permalinks: Avoid a PHP notice in `get_permalink()` if default category is unavailable. Props Presskopp. Fixes #36529. git-svn-id: https://develop.svn.wordpress.org/trunk@37707 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/link-template.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 0d06a3f9ca..164bcd905c 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -191,7 +191,9 @@ function get_permalink( $post = 0, $leavename = false ) { // having to assign it explicitly if ( empty($category) ) { $default_category = get_term( get_option( 'default_category' ), 'category' ); - $category = is_wp_error( $default_category ) ? '' : $default_category->slug; + if ( $default_category && ! is_wp_error( $default_category ) ) { + $category = $default_category->slug; + } } }