Support » Plugin: Admin Columns » [Plugin: Codepress Admin Columns] PHP error with multiple posts types when searching posts in wp-adm

  • Resolved Scott Salisbury

    (@scottsalisbury)


    Hi there,

    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:
    http://www.scottjs.co.uk/photos/wordpress/wp-error.png

    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:
    http://www.scottjs.co.uk/photos/wordpress/custompress-search.png

    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.

    Cheers,
    Scott.

    http://wordpress.org/extend/plugins/codepress-admin-columns/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tobias Schutter

    (@tschutter)

    Thank for reporting this and the very clear description of the issue. I will have a look and come back to you.

    Plugin Author Tobias Schutter

    (@tschutter)

    I will add your fix for this in next release, probably v1.4.7. I have removed my old response which was to typecast it to an array.

    Thanks again for the report and fix!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Codepress Admin Columns] PHP error with multiple posts types when searching posts in wp-adm’ is closed to new replies.