Closed jonathanstegall closed 4 years ago
@jonathanstegall Hi, do you have a stack trace by any chance for that notice? Is it just viewing any author archive to reproduce?
Sorry for my delay here. I've not been able to reproduce it again. I think it may have been conflicting with a third party plugin's problems, which have since been fixed. I think this can be closed.
@rebeccahum I'm running into this issue on a site. We are using Co-Authors for author archive pages (example) and see this warning come up whenever we use template related WordPress functions like get_page_template()
and get_page_template_slug()
.
I'm able to get around this by using this filter, but I wonder if this should be resolved in the plugin instead of a filter:
/**
* Adds any filters necessary for the Co-Authors Plus Plugin.
*/
class CoAuthorsPlusManager {
/**
* Runs this manager.
*/
public function run() {
add_filter( 'coauthors_guest_author_fields', array( $this, 'add_post_name_property' ), 10, 1 );
}
/**
* Adds the post_name property to the guest author fields.
* This doesn't do anything, but prevents PHP warnings from firing on an individual contributor page.
*
* @param array $fields_to_return The fields to return.
*
* @return array
*/
public function add_post_name_property( $fields_to_return ) {
if ( is_array( $fields_to_return ) ) {
array_push(
$fields_to_return,
array(
'key' => 'post_name',
'label' => '',
'group' => 'hidden',
'input' => 'hidden',
),
);
}
return $fields_to_return;
}
}
I'm not sure if this is new or if I've just not noticed it before. When I load an author archive on my local install (running version 3.4.3), I'm seeing this:
Doing an error_log on
$post
at that template.php file returns:I took out the individual values from those keys, but they're all what I would expect for an author. I can see that there is a
post_name
key in the database. I think I would've noticed this before, but I don't remember ever seeing it, so maybe it's a new issue?