I'm detecting if the user has a gallery in his post:
$gallery = get_post_gallery( $post->ID, False );
$gallery_images = explode( ',', $gallery['ids'] );
And at times I'd like to see how many columns it has:
var_dump( $gallery['columns'] );
This works for 2 columns, it returns 2
but if I were to set the columns to 3, it breaks, throwing the error:
<b>Notice</b>: Undefined index: columns in <b>C:\file.php</b> on line <b>45</b>
Note that 4, 5 columns work just fine, but 3 won't. This only happens when there's a second gallery in the post.
How is this possible?
column
key dont exists in the array. So you could check if the array-keycolumn
exists. See my answer...