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
- Rename a table in MySQL
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- How to call a JavaScript function from PHP?
- Access PHP variable in JavaScript
- Keeping WP database synced across multiple developers using git
- How to define composite keys with dbDelta()
- Connect forms in WP to external database
- How to get site URL if database is disconnected?
- Is it wise to delete post revisions and autosaves from database?
- Multiple WP install with same users database
- Using two different DB users on one WP install
- Usage of Direct Database Call Without Caching Error
- Can I transfer a mysql database to another site?
- Weird issue with database migration and SSL links
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- Backup another database with BackUpWordPress plugin [closed]
- Easiest Way to Authenticate WP Users Using an External DB?
- How to use a different database to list and manage comments in the backend
- Using shipped version of jquery
- Trying to implement Ajax comments in WordPress, getting WP error
- SQL QUERY – Select a value directly from the database
- add mediaelement.js plugins into WordPress video player control bar
- Why is it that not all users have a ‘session_tokens’ meta_key record in the usermeta table?
- Javascript file is not working on single.php wordpress [closed]
- How to send Ajax request from my plugin in admin dashboard?
- How to have an external DB read and get data from my wordpress database
- Customizer: Multiple CSS styles on same element in Live Preview
- AJAX success response is not working but it’s saving my changes
- Using TinyMCE in plugin?
- Execute a function every hour in the background
- Create page with custom php script and fetched data
- restore a db after bad backup
- Best practice to import user base (subscribers) from one website to another?
- Most commented posts by time period (last 12h, last 24h and etc)
- Some weird users in database
- get specific value of a array | PHP
- Location of image metadata on my server
- How to create more than one new wpdb object?
- Is it good practice to import/export a blog to test a redesign?
- Getting value from database table depending on field value
- Getting “Error Establishing a Database Connection” on localhost in new Mac OSX Lion environment
- Secure way to use name_save_pre?
- wpdb->insert not inserting first variable
- Database tables for sports betting integrated in WordPress
- Is it possible to isolate and use WordPress functions outside of wordpress
- How to use multiple check-box values to work in a function and insert values in database
- Testing a Form’s Zipcode Field with Regular Expressions to Determine WordPress Page Behaviour
- New installation fatal error in 5.9.3 at edit or create entry
- Storing transients giving database error
- I want to replicate a wordpress website over multiple servers
- Is there anyway to split posts to different databases?
- wp-cli + valet: “Error establishing a database connection”
- Search bar for wp menu
- local wordpress broke after changing URL
- Get Shortcode output to database for static post_content
- How can i show specific Category List?
- Using Javascript On Page – Header and Footer Now Missing
- Unable to login to a https website via the app after changing from http
- Is it safe to add INDEX to a column in WordPress database?
- Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
- sessionStorage saves input value in browser but it is not loaded in the form field
- Restore Old Database Over Newer WP & Plugin Files
- Speeding up WordPress on a Local Network
- How do I find out from my database what version of WordPress I need?
- How to create a database table?
- Extracted CSV as Array for Custom Query Loop
- Hang Up Followed By Can’t select database
- Embed Javascript code to registered users only
- One WP Database outside localhost and two connections
- Accessing external database: ERR_INCOMPLETE_CHUNKED_ENCODING
- How to set up php,javascript and css to allow for our finished product to be displayed within a page?
- Dynamic Gallery
- Create hundreds of users with just ID in phpMyAdmin
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- wp-config was suddenly updated
- How to get the last date updated of postmeta?
- Order of search results based off of a backend custom field and also in alpha order
- How to find fresh (last modified) and sql backup?