Problem Over a few years there are large number of photos in facebook. The MPP want to copy all the photos in facebook to his own gallery on his website. The gallery on the site is using plugin - Envira Gallery. Normally, we create a gallery by drag-drop photos one by one, then place the shortcode on to a post or page. Now we have created all the gallery, the next step is to create posts to acommodate these galleries. The problems left are create posts for each gallery how to please handreds of gallery posts to the menu add featured image to each post Basic informaiton Envira Gallery stores gallery in wp_posts table with post_type = 'envira'. Regular posts are stored in the same table with post_type='post'. The data for the photos in a gallery is stored in wp_postmeta table with meta_key = '_eg_gallery_data' Category information is stored in wp_term_replationships table with object_id = post_id, term_taxonomy_id identifies its category, for gallery term_taxonomy_id=32. Solution Create post list using plugin Advanced Post List. Add posts for each gallery in batch List gallery title, gallery ID in excel in order to generate sql statement to create posts. The formula for cell D3 as following. =$D$1&"(1,'"&YEAR(C3)&"-"&MONTH(C3)&"-"&DAY(C3)&"', '"&YEAR(C3)&"-"&MONTH(C3)&"-"&DAY(C3)&"','[envira-gallery id=\"""&A3&"\""]','"&B3&"','','publish','closed', 'closed','','"&SUBSTITUTE(LOWER(B3)," ","-")&"','','','"&YEAR(C3)&"-"&MONTH(C3)&"-"&DAY(C3)&"','"&YEAR(C3)&"-"&MONTH(C3)&"-"&DAY(C3)&"','',0,'http://domain.com/?page_id=', 0,'post');" The formula on cell C3 as following. ="2018-"&IFERROR(MONTH(LEFT(RIGHT(B3,6),3)&" 1"),MONTH(LEFT(RIGHT(B3,5),3)&" 1"))&"-"&RIGHT(RIGHT(B3,6),2) Change create date for galleries. This is not necessory, but to do this we can use this script in excel cell F3. ="update wp_posts set post_date='"&YEAR(C3)&"-"&MONTH(C3)&"-"&DAY(C3)&"' where id="&A3&";" Set Featured Image to posts Using the first photo in gallery as the featured image.…