Is this what you are asking for? Use it after the code you posted to create posts in loop and use thier ids to update meta fields. Replace “post_type” with your custom post type.
foreach ($markers as $marker){
$post_id = wp_insert_post(array(
"post_title" => "something",
"post_type" => "your-type",
"post_status" => "publish", //by default they are drafts
// etc.
));
update_post_meta($post_id, "latitude", $marker['lat']);
update_post_meta($post_id, "longitude", $marker['long']);
}
After that you can get those fields by using get_post_meta()
Related Posts:
- What is this JavaScript “require”?
- What is this JavaScript “require”?
- Display data from a non wordpress database on a page template
- Saving Metadata from the Gutenberg Editor Sidebar to the Database
- Dynamic data in `wp_register_script` needed
- Integrating PHP into Javascript to display map markers with Google API
- Run a Parallel PHP Application with WordPress
- Access/update database with jQuery
- Putting PHP variables into javascript [duplicate]
- Integrating PHP into Javascript to display map markers with Google API – problem with wp_localize
- PHP array to JS array to use in google map
- Understanding WordPress Search
- PHP variables in a post?
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- Filtering markers on google map by WordPress category[SOLVED]
- Generate a radius search of custom post type locations
- Full search and replace isn’t enough to make all pictures to be loaded with https
- Querying latitude and longitude into google maps correctly
- Transforming an wp_options database array into a javascript obect?
- wordpress database error
- Problems with plugin that fetches data from database with ajax
- notify users when changed database
- How can i add a script with parameters?
- google my maps ~ custom map embed into wordpress
- How many users can WordPress handle?
- Site stuck in “Database Update Required” loop
- WordPress database scalability from the code perspective
- WordPress Unit Testing – Cannot Create Tables
- Inserting dynamic content into a page
- Check if post of title already exists
- How to call a PHP function from Javascript in WordPress
- Why term_id is not indexed in wp_term_taxonomy table?
- Presentation vs Content in WP DB-Tables
- how do I determine which image is the featured image in the database
- Why does dbDelta() not catch MysqlErrors?
- WordPress admin never finishes saving page on site with large page count
- Is altering a default WordPress database table update safe?
- Change all http to https in mysql databse?
- WordPress DB: options-table –> 32 gzipcompression?
- Having issues with wp_postmeta and wp_usermeta tables too big
- How to prevent WordPress from retrieving data for the last 10 posts in the database?
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- How can the plugin directory path be returned into ?
- How to retrieve and show database table in wordpress dashboard
- Moving to another host; which tables to move in a database
- Show post in slider
- WordPress mysql table double prefixes
- How can I transition a site from using the Beta Tester plugin to a “normal” install?
- Storing data for a wordpress plugin
- Transient feeds and caching error
- $wpdb doesn’t like to store arrays
- Connect to a remote database for wordpress in my own hosting server
- Need Help Fixing My Iframes [closed]
- Update results, Before deleting the related category [closed]
- What Is the Proper Way to Merge Usermeta Table to a an existing WP Database?
- Importing CSV into database table not working?
- database sent to a JSON file
- Accessing WPDB Multidimensional JSON Array w/ Javascript
- Databases – Submitting data from inputs to database [closed]
- What does wp_term_taxonomy.parent reference?
- How to combine multiple wp_insert_post into one in order to gain better performance
- Two prefixes in database? Which one is valid?
- How can I restrict php mail() to only send me one email after a db error
- pull data from a remote wordpress database
- Users table missing from Database [closed]
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Why does changing Database Table Prefixes result in loss of content?
- Incrementing PHP variable onclick to display posts by month
- How to connect and insert data in database of wordpress?
- wp_option table error while importing
- wp_insert_user not creating account correctly when ID is manually set
- Installing local to live WP into subdirectory
- Variation prices breakdown only for single product page
- Cant create table on plugin activation
- How to use wp_ajax_set_post_thumbnail?
- Display user data in numbered list
- Passing a value from an input field to a php function in WordPress?
- Google CSE Malfunctions via Chrome/Safari on Mobile When Clicking on Either Search Icon/Menu Icon. How to Make Google CSE Default Theme Search
- How do I change several broken URLs in a several wordpress databases in the fastest way?
- Best way to store 1 billion+ posts?
- Show subcategory name selected in specific category woocoommerce
- Move Jquery.js to Footer
- Updating the database after parsing CSV document
- Post title and url not showing on google map marker [closed]
- Character encoding issue – black diamond question marks on imported post excerpts
- WordPress Migration – Issue with admin panel changes
- Reinstall wordpress/mySQL caused database problem
- How To connect to the same WordPress database with different database user
- I have include wp-config, should I add global $wpdb also?
- How to have WP Search widget index dynamically generated content?
- Preventing concurrent update of data
- How to save information related to post in database?
- Category not displaying in add post, edit post, and categories page.
- $wpdb->prepare returns empty array
- Prevent creation of unused database tables?
- How to store a plain password in WordPress database in another field
- How to stop WordPress from using utf8mb4_unicode_ci collation
- wp-config was suddenly updated
- How to find fresh (last modified) and sql backup?
- Add tags to blog-posts by php-script