This may well be a bug in WordPress or CodePress Admin Columns or a combination of the two, or something else.
I’m using a plug-in called CustomPress by WPMU Dev, which allows you to create custom post types and taxonomies. It also provides the ability to add your custom post types to WordPress’s search functionality.
If I have more than one custom post type which are both added to WordPress search, then do a search in the wp-admin backend, CodePress Admin Columns fails with the following PHP error:
Warning: Illegal offset type in isset or empty in /var/www/trunk/wp-content/plugins/codepress-admin-columns/codepress-admin-columns.php on line 1654
Screenshot of error:
I’ve tracked this down, and it appears that the cause is on line 220 of codepress-admin-columns.php:
return $this->add_columns_headings( get_query_var('post_type'), $columns);
The problem is that get_query_var(‘post_type’) returns an array if there are multiple post types added to WordPress search, instead of a string.
Screenshot of post type search options in CustomPress:
I found that replacing get_query_var(‘post_type’) with get_post_type() fixes the issue for me.
I’m not sure if this is the best way to fix this issue, but it worked for me. I tried alternative plug-ins other than CustomPress to enable custom post types on WordPress search, but all my attempts rendered the same results and the only way to fix it was to do as above.
I hope this helps.
- The topic ‘[Plugin: Codepress Admin Columns] PHP error with multiple posts types when searching posts in wp-adm’ is closed to new replies.