The problem is a basic PHP problem rather than a WordPress problem.
wp_insert_post
is expecting 'post_content'
but you’ve given it '$post_content'
and it needs a string as it’s value aka "[gd_shortcode]"
not [gd_shortcode]
.
The same is true of your post status, it has a $
in it that should not be there.
See the examples at the official dev docs at https://developer.wordpress.org/reference/functions/wp_insert_post/ for proper usage of wp_insert_post
Related Posts:
- What’s the difference between term_id and term_taxonomy_id
- How do I programatically insert a new menu item?
- When would I use either function for plugins?
- Test to see if jQuery or Prototype is queued by another plugin?
- Custom Nav Menu items default to ‘menu-item-type’ => ‘custom’. How to make a “page” menu item?
- How to tell if an option has been created vs an empty option?
- jQuery in header or footer
- Notice: _usort_terms_by_ID is deprecated since version 4.7.0! Use wp_list_sort instead
- How to add a new plugin page under desired Options page?
- Plugin screenshots not showing in the repository
- How to make WordPress use non-greedy shortcode parsing?
- Multiple Parameters for a Shortcode
- How to get current page name in my wordpress plugin
- WP Cron doesn’t save or in post body
- Use register_taxonomy() in register_activation_hook()
- Pages 404 in wordpress
- How to properly load text domain of custom mu plugin
- Post from front-end with post types, categories and taxonomies
- product-attribute-slug-is-too-long-28-characters-max
- Calling apply_filters on non-documented hooks
- Multiple entries in get_option results? or why is _multiwidget set to 1?
- Check if I am in the Admin Panel (wp-admin)?
- Fully automated theme install and activation via a plugin
- Using Ajax call in jQuery doesn’t work in widget
- Why is WP_Mock not used instead of WP_UnitTestCase for writing unit tests by most plugins?
- Confusion on WP Nonce usage in my Plugin
- Metabox Not Showing on Custom Post Type But On Pages and Post
- Using Checkboxes on Plugin Options Page for Custom Plugin
- Add media and attach images to pages
- Create a Page via plugin
- Generating User(s) with Settings API
- How to redirect to action on custom page within admin section
- Show comments fields in two columns
- Processing shortcodes in groups (separated by line breaks)?
- How to convert this cURL to wp_remote_get?
- Including a JS source with an admin page
- Should action callbacks start with a verb?
- How insert negative values in Gutenberg box-control
- WordPress setting with select – where is my mistake?
- What filter should I use to insert a button inside on Media>Add New
- is user logged in not working
- Override class inside $atts shortcode_atts in WordPress
- How to use a hook to override an update_post_meta call in a plugin?
- External Authentication, session_tokens not destroyed on logout
- Display custom fields in frontside user profile
- Strange issue saving custom field data for a WooCommerce order
- How to programmatically add a custom template that appears in Site Editor from a plugin?
- In woocommerce cart item we can add custom text but how can i add custom link? [closed]
- Is it possible to restrict all admin pages except theme customisation and storefront using plugin?
- Updating Woocommerce Settings API when WordPress Settings API saved and vise versa
- Build a translation correcter plugin
- Secure REST with nonce works only when not logged
- template_include filter does not render the custom template
- How to give a download link to a .csv file from the custom plugin?
- What’s wrong with this post__not_in argument?
- How to set a cookie for logged in users to md5($user->ID . “my_secret”)?
- WordPress plugin enqueue scripts working for js, but not css files
- First and last name fields not filled when using wp_insert_user
- Meta box on options page save form problem
- my basic php code producing unexpected results
- Sending an SMS on new order placed – WooCommerce
- Where to use nonce
- Gutenberg – is it ok to load dependencies multiple times?
- How to show parents of current page category, excluding the category?
- get_plugins() is not give plugin list after performed delete_plugins()
- Best practice for Designing a Plugin with this scenario
- Overwriting a plugin function
- Referencing files in JavaScript in WordPress Plugin
- How do I debug an error that a plugin is causing?
- What could cause a WP Option to get truncated?
- Borrowing of Previously Translated Strings by Child Plugin
- How to call function from another plugin?
- Ajax on the Administration Side of plugin – returns 0
- Add custom product data using javascript when add to cart button is clicked
- Creating a WP plugin and having issues linking CSS stylesheet within functions
- How to enhance a self developed plugin by its own plugin architecture
- What happens/fires when you select a block in the editor?
- Determine if term is Category or Tag
- Disabling Yoast, All-in-One, and Rank Math on Certain Pages within a Plugin
- How to hide/remvoe unnecessary field/section in post edit section ( Dashboard )
- Stuck on a 504 error
- How to set a public variable in someone else’s plugin class
- Change Front page displays settings conditionally when user is online
- How to enqueue an external Javascript file to Frontpage footer
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- Woocommerce Custom Checkout
- sql query not working in wp plugin
- get_users() not returning all users in site
- Simple Search Plugin Does Not Perform Search
- User subscription emails not firing from custom plugin
- Creating an archive page listing external data
- save_post not called in plugin / custom field still saving overwriting metaboxes
- Custom slug in url for CPT and taxonomy
- How specify a directory to file when downloading it
- Need edit profile link in the menu for logged in users
- Create a Custom Login System in WordPress [closed]
- Why isn’t my readme.txt file being read
- How to update WordPress Plugins in your own maintance application?
- register_setting registered with incorrect data type
- Admin Menu for New Post