Breadcrumbs error in author archive page
-
Hi.
Error:
PHP Notice: Trying to get property ‘ID’ of non-object in /var/www/html/wp-content/plugins/seo-by-rank-math/includes/frontend/class-breadcrumbs.php on line 442
Your function should not make use of global $author:
private function add_crumbs_author() { global $author; $userdata = get_userdata( $author ); $this->add_crumb( sprintf( $this->strings['archive_format'], $this->get_breadcrumb_title( 'user', $userdata->ID, $userdata->display_name ) ) ); }
Instead make use of something related to the main query:
private function add_crumbs_author() { $userdata = get_userdata( get_query_var('author') ); $this->add_crumb( sprintf( $this->strings['archive_format'], $this->get_breadcrumb_title( 'user', $userdata->ID, $userdata->display_name ) ) ); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Breadcrumbs error in author archive page’ is closed to new replies.