The code does not adds posts twice – checked in my local installation.
You have got errors in it:
$my_post = array(
'post_title' => $title,
'post_date' => $insDate,
'post_content' => '$url',
'post_status' => 'public',
'post_type' => 'post',
);
Should be
$my_post = array(
'post_title' => $title,
'post_date' => $insDate,
'post_content' => $url,
'post_status' => 'publish',
'post_type' => 'post',
);
Otherwise, the problem will be in the form posting the variables. Maybe it get’s redirected and is submited twice, or something similar.
Related Posts:
- Manually set global $post vars with an ID, in order to use template tags
- How can I make it so the Add New Post page has Visibility set to Private by default?
- Show Similar Post Titles ( Similar to Stack Exchange )
- How to add option box in “Edit Post” plugin API?
- How do I unlock a post programmatically?
- How To Ignore a Filter On Applying Filter the Content In a Function
- How to get posts by content?
- Publish Post After Click On A Link
- Fastest way to loop through all posts?
- post expire after x days
- Action on post publish
- How use %like% in sql statement wordpress
- Adding Attachment Display Settings in custom media frame
- Execute a plugin only on post pages
- finding whether request is for post, and post id
- Display post lists in 2nd paragraph
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- Redirect to another page using contact form 7? [closed]
- Recent posts per category loop?
- Import Instagram post to WordPress blog post
- Bulk update wordpress posts
- How to get all posts belongs to a user between a certain date
- Loop in elementor custom widget not working
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Post status doesn’t update to ‘future’ every time?
- Show related posts based of current ACF field name in a single page post (a loop within loop)
- Remember the Meta Value With Radio Buttons
- Delete data from custom table when deleting a post
- How to get Recent Post From Each Category with Thumbnail?
- help intercepting save_post through plugin
- Is it possible to pin a post in second position from top
- i need to make custom cron_schedule with custom interval time as a parameter into a custom payment gateway plugin wordpress
- Help to Create a Simple Plugin to make a post
- How to display the custom post related blog by category?
- WP Forms not displaying,becomming an fatal error
- How can I see $post object in frontend from functions.php?
- Allow members to create groups on my site
- add tags to wordpress post using REST API
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- WordPress Product Detail and catalog
- Is it possible to create duplicate post on other site (either push, on publish, or pull, periodically)?
- How can I get the Post ID and Post Type within a Must Use Plugin?
- Get content and send to 3rd party
- Displaying friend’s posts only
- Multiselect value in wp_query
- Get page type to display content
- Capturing POST data
- single.php fires more than once after clicking on any post to view with different post id each time
- Custom feed parameters / Template overriding
- Plugin to display text before a post
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- Outputting custom field query from a plugin to the website header
- warning wp session
- How to add a shortcode button to the TinyMCE editor?
- Plugin upgrading: Widget settings
- Create a table in custom plugin on the activating it?
- How would you require and automatically download dependent plugins?
- Understanding apply_filters
- Editor not displaying dynamically after clicking on the button
- Replace existing pages with new pages, keep menu links
- How to submit documentation with plugin
- Placement of Code in Plugin for hooking `save_post`
- gallery option is not available in media upload box in costum theme option page
- New post notification plugin [closed]
- How can plugins have their own pages?
- Reusable functions and tools (Framework)
- Creating a plugin to sanitize comment and the url field before display only
- Object Oriented Plugin not working
- Creating mySQL procedure with $wpdb
- Editable form for WordPress plugin options page
- remove add new post, if there is already one post
- Change the display of Settings API (do_settings_sections)
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- WordPress Jquery UI Spinner
- How to backup single post in wordpress [closed]
- How can I modify admin bar only if my plugin is loaded
- Allowing users to Sign-up > Login > Post articles that need approval
- Adding custom meta boxes to specified custom post type
- How to write to a separate PHP file in plugin settings
- Get post content from outside the loop with plugin shortcode usability
- Custom CSS not being added by plugin
- How to add custom function to pluggable.php
- Remove Zero Money From Previews Order woocommerce
- Access remote SFTP server via WordPress login?
- Shortcode do not return the right data in post
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- Avoid WordPress header bar when form submission using admin_post in the frontend
- Echo custom admin field into a is_single()
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- Hide ‘add to cart’ button for some products [duplicate]
- Add Flatr button to Sharing option
- Change localization only for plugin
- How to get author developer link on plugin page
- wp_schedule_event need to deactivate plugin changing recurrance
- Customize Multi-Column Tag Map to fetch specific post-type
- Upload Image to desired directory through plugin
- add_meta_box showing blank screen in my page
- Plugin translations are not loaded from translate.wordpress.org
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class