I want to generate short code for my gallery dynamically. For a single gallery, it is easy to create a short code for my gallery using
add_shortcode( 'image-gallery', 'gallery' )
Now my question is how can i create multiple short code for multiple gallery? Like for gallery 1 short code will be image-gallery-1, for 2 code will be image-gallery-2. I've tried this way
$all_gallery = $wpdb->prefix . 'gallery';
$all=$wpdb->get_results("select * from $all_gallery");
if(count($all)>0){
foreach ($all as $a){
add_shortcode( 'image-gallery-'.$a->id, 'gallery' );
}
}
Its working nicely but when i deactivate the plugin and then activate the plugin again, a fatal error occurred and plugin is unable to activate.