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 include code into functions.php file via a plugin
- building plugin and it is displaying above plugins page
- like to keep reading plugin
- Check if email address exists front end with AJAX in a plugin
- Avoiding Duplicate function names in Post Loop (WP_Footer script)
- Output HTML only on individual post view
- Default Plugin Settings Not Writing to Database
- add action for displaying posts using a shortcode
- How do I write into a file (css)
- Using the “Latest posts” feature on a different site
- WP Plugin Developers – Accessing my wordpress site [closed]
- How to make a custom field as an editor in wordpress?
- WP_Query ordering numbers as letters
- WordPress Automatic Plugin Update Renames Plugin Directory
- How can sanitize $_FILES[‘haq_slider’] field
- Why is an action callback function from an instance of a class always invoking the same function from an instance?
- Write to / remove from default .htaccess file from plugin?
- ‘wp_login’ action hook not working with wp-login.php file
- Is it possible to enqueue CSS files from plugin before theme’s CSS files?
- Update Option Error: Notice: Undefined index
- Why this global array is returning NULL from a callback function
- Demystifying and understanding shortcode nomenclature
- Post query – show posts from specified day and month and whole years
- How to define WordPress plugin shortcode globally for multisite?
- download_url() appears as grey icons
- Global matrix for shortcodes/content for every page
- Plugin not appearing after uploading it via FTP
- How to add class in plugin only for network site?
- load_theme_textdomain path
- how to Include json manifest file in wp plugin
- Plugin Development sqlite or WordPress’ database
- Is there any way to get all the name or slug of template parts used in a page?
- Dynamic CSS Vs Inline Issues in Code any Way around in a WordPress Themes?
- Is license need for free wordpress plugin
- How to make Http Request to a php file present in plugin directory of wordpress
- Create a custom page template inside my wordpress plugin
- Retrieving plugin options value saved through setting
- Best way to hook a custom url?
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- Is there a way to order posts and custom post types as one group?
- Read text defined under __()
- How to change commenter links to /user/user_id?
- Display content from custom post type if match to main post category
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- What is the best way to mimic a search query within a plugin
- Next and/or previous post content
- Serialize data for wp options