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?
- can not serialize and insert data from custom form
- Cannot update custom database table row
- Search and replace special characters (å,ä,ö) for image attachments only in database
- Google Map iframe in a tab issue
- wpdb_prepare with multiple or condition
- Accidentally deleted active_plugins portion of the wp_options DB table
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- How do I copy a wordpress database?
- One post carries 30 postmeta values, is this too much?
- Add custom php database code above
- Export all content from wordpress
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- WordPress doesn’t show all posts in database
- Is it possible to split database tables using HyperDB?
- Adding new row to wp_post table
- Make id column as AUTO INCREMENT on plugin activation
- How to make custom total price reactive in navigation
- Adding tawk.to code just before body tag on functions.php file
- How do I fetch all comments per post via WP REST API?
- Deregistering a script in WordPress seems impossible
- Slide in Panel WordPress Post
- wp_insert_post not working
- For WordPress is there content in the database which I can safely ignore?
- Proper way to edit a post via phpMyAdmin without breaking the compare revisions tool
- Sending jsPDF documents to the server
- How can I UN-orphan media files?
- How to check if a core update, like 4.9.8 → 5.0, involves a database update (migration)?
- Show content from database
- How to prevent those PHP variables from being cached on WordPress?
- Automate dir and DB stack creation with WP-CLI
- Ajax return code 400
- Customize JSON output
- Does WordPress always create unique passwords?
- Show last modified date of database
- Pass a php string to a javascript variable
- How can I add an alert (like the old javascript alerts) to my WP page?
- Uppercase to sentence case for post titles
- $wpdb->insert is not working
- WordPress Install and Database on separate hosting?
- Moving a site from a temporary domain to the live domain [duplicate]
- Pass PHP variable to JavaScript without inline JS
- How to retrieve and show database table in wordpress dashboard
- Moving to another host; which tables to move in a database
- Store and Work with huge array in WP [closed]
- Show post in slider
- How can I output a php value into a JS file within WordPress?
- Error: SELECT SQL_CALC_FOUND_ROWS
- What happens if I overwrite the current wp_options table with a backup from a week ago?
- WordPress mysql table double prefixes
- Error establishing a database connection on Installation
- SQL Error wp_commentmeta – incorrect table definition
- Import live site to local setup without access to live site
- Using shipped version of jquery
- Adding custom tables to WordPress
- phpMyAdmin displays error when importing database
- Extracting the post_id via the wp_insert_post action (external db query)
- WordPress database error – Error in SQL syntax – I can’t identify any error?
- How to interact with another wordpress install on same database?
- A field with dashes in the slug [closed]
- How can I create a Bible search engine via WordPress? [closed]
- Prevent Data Resubmission On Page refresh
- Bridging TinyMCE js and WordPress PHP?
- Moving WP from local server to live, error establishing a db connection
- CRUD operations using WordPress database API
- Merge two WordPress installations into one, and keep posts separated?
- Moving online website to MAMP or dumb idea?
- Adding Custom Forms
- Display SQL that wordpress is running
- How can I transition a site from using the Beta Tester plugin to a “normal” install?
- What is this in my tables
- delete post meta from db, even if does not exist?
- In what part of the WordPress core does the users table and usermeta table get joined?
- Critical error in final stage of website launch – URLs are BROKEN!
- Are custom tables in the database overwritten when WordPress is updated to new versions?
- Trying to implement Ajax comments in WordPress, getting WP error
- SQL QUERY – Select a value directly from the database
- SQL Query to Update Admin Email