Last active
December 18, 2015 00:38
-
-
Save ny0m/5697529 to your computer and use it in GitHub Desktop.
PHP function to fix Wordpress error "Undefined property: stdClass::$labels in general-template.php (for this Trac ticket: http://core.trac.wordpress.org/ticket/20994). I needed it to fix the title send in an RSS feed for my custom taxonomy, but helps with quite a few edge cases. Just paste into functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('pre_get_posts', 'fix_title'); | |
function fix_title(){ | |
global $wp_query; | |
if ( $wp_query->is_post_type_archive && $wp_query->is_tax ) { | |
global $queried_object; | |
$queried_object = get_queried_object(); | |
$queried_object->labels = new stdClass(); | |
$queried_object->labels->name = $queried_object->name; | |
return $queried_object; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment