Skip to content

Instantly share code, notes, and snippets.

@thefrosty
Created September 30, 2011 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefrosty/1254314 to your computer and use it in GitHub Desktop.
Save thefrosty/1254314 to your computer and use it in GitHub Desktop.
Getting foreach error on empty posts..
function columns( $columns, $post_type = 'post' ) {
$post_type = get_post_type();
if ( !post_type_supports( $post_type, 'thumbnail' ) )
return;
if ( !$columns )
return;
if ( !WP_List_Table::has_items() )
return;
$new = array();
foreach( $columns as $key => $title ) {
if ( $key == 'title' ) // Put the Thumbnail column before the Title column
$new['featured-image'] = __( 'Image', self::domain );
$new[$key] = $title;
}
return $new;
}
WARNING: C:\xampp\htdocs\demo\wp-admin\includes\class-wp-list-table.php:661 - Invalid argument supplied for foreach()
WARNING: C:\xampp\htdocs\demo\wp-admin\includes\class-wp-list-table.php:631 - array_keys() expects parameter 1 to be array, null given
WARNING: C:\xampp\htdocs\demo\wp-admin\includes\class-wp-list-table.php:631 - array_intersect() [function.array-intersect]: Argument #1 is not an array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment