Created
November 3, 2022 14:38
-
-
Save kbcarte/541d659751fed4a88c4cdf7b1bbbcab8 to your computer and use it in GitHub Desktop.
Insert new location pages based on array of city names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// example of FL | |
$imports = array('Brooksville','Spring Hill','New Port Richey','Hudson','Port Richey','Holiday','Dade City','Zephyrhills','Wesley Chapel','San Antonio','Kathleen','Webster','Saint Petersburg','Clearwater','Clearwater Beach','Largo','Seminole','Pinellas Park','Palm Harbor','Tarpon Springs','Safety Harbor','Dunedin','Odessa','Lutz','Tampa','Land O Lakes','Thonotosassa','Plant City','Lakeland','Auburndale','Bartow','Eagle Lake','Mulberry','Winter Haven','Brandon','Dover','Gibsonton','Lithia','Riverview','Ruskin','Apollo Beach','Sun City Center','Seffner','Valrico','Wimauma','Palmetto'); | |
foreach( $imports as $i ){ | |
$page_id = wp_insert_post( | |
array( | |
'comment_status' => 'close', | |
'ping_status' => 'close', | |
'post_title' => $i, | |
'post_name' => strtolower(str_replace(' ', '-', trim($i))), | |
'post_status' => 'publish', | |
'post_content' => '', | |
'post_type' => 'location', | |
'post_parent' => '7083' // id of the parent state page, FL in this case | |
) | |
); | |
} | |
echo "<h1>All done!</h1>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment