I want to create galleries for my posts working like this :
- I choose pictures in wordpress post-new page and upload them
- Wordpress creates an array of those images uploaded
- And finally i use that array and put gallery into my single.php file
Actually woocommerce is using the exact thing as you see in the picture ( sorry i didn't have English wordpress installed )
any suggestions?
you can use the default gallery behavior to your need
Insert a gallery in tour post, it will create a shortcode like
[gallery ids="12,45,67,34"]
override the default gallery shortcode function to not display it in your post
remove_shortcode( 'gallery', 'gallery_shortcode' );
add_shortcode( 'gallery', 'my_gallery');
function my_gallery(){
return '';
}
retrieve an array of images ids
$post_content = get_the_content();
preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
if($ids){
$array_id = explode(",", $ids[1]);
}