fix pagination in global gallery shortcode and format code