It appears that you can ask wp_insert_post()
to return a WP_Error
on failure by setting the 2nd parameter to true
(it defaults to false).
So if you change
$new_article_id = wp_insert_post($new_article);
to
$new_article_id = wp_insert_post( $new_article, true );
in your code, you should get WP_Error
objects back that you can then inspect.
Related Posts:
- Return $post_id when DOING_AUTOSAVE?
- Including Angle Brackets In Pre Sections
- Anchor Text code string is automatically modified by WordPress
- WordPress is converting & to & inbetween [code] brackets
- Notice: Undefined property: wpdb::$current_post What can be wrong?
- Where to save common libraries?
- source code: WP_INSTALLING vs. WP_SETUP_CONFIG in setup-config.php
- Sublime Video: Playlist which gets all attached videos
- Code Friendly Block Quotes
- Remove line breaks from ?
- How to fix a “globals” issue to avoid a rejected theme?
- Need resource on available functions and objects
- I want to remove the home page header image from all other pages
- Proper implementation/use of code/syntax highlighting
- How to remove all comments from JS, HTML, CSS files?
- What data validation we must use in different contexts?
- Need To Post Unformated Code
- Sidebar login: How do I get the username to show after “Welcome”?
- How to manage multiple wordpress project with shared code base
- Block IP Addresses using Code [closed]
- Find Total Authors
- Why does HTML entities are still encoded in Code Block?
- How to create a checkbox to show/hide a field in WooCommerce checkout [closed]
- how to display google maps with javascript
- How to pass https://achecker.ca/ validator? [closed]
- How to write custom code on WordPress?
- Remove Metaboxes
- Google analytics won’t work in wordpress
- Where do I add an action hook & callback in my theme?
- How do I reset my footer.php to its original state? (theme: Origami)
- Commenting out in HTML editor breaks template
- wordpress prepare error
- Adding code to send referrer on login page
- Table styles disappear when updating content
- Manage recurring event time
- wp_editor save all content
- Need an elegant solution to declare the value of two variables based on the count of the post
- How to insert integration code for CRM?
- A good way to include snippets of code in both posts, pages and Event Manager Template files?
- Anchor Text code string is automatically modified by WordPress
- Return $post_id when DOING_AUTOSAVE?
- Changes in code only show after changing theme
- Code Highlighting in BlockQuote
- feed url problem
- Where do I go to add a tag before the closing body tag?
- Upload Multiple Files With media_handle_upload
- What is this code in my theme’s functions.php? if (isset($_REQUEST[‘action’]) && isset($_REQUEST[‘password’])
- Copyright info change in Theme Child PHP
- How to link to a alternative page in CSS
- I want to remove the links from the term list returned by get_the_term_list
- Admin Notices coding standard issue
- Completely disable RSS feeds on WP 5.5.2 and show a 404 page instead of die();
- How to display php source code inside a post using visual editor?
- WP-Markdown treating java generics like HTML tags
- how to attach an image to a custom post type in wordpress using just code
- How can I upload an image for background use using the Theme Editor in WordPress?
- Adminbar Missing “Edit Page”
- Nested Code Snippets [closed]
- code is working properly in Core PHP but writing coding in WordPress
- I got an issue after i migrated a site
- How to save inputed data in a textbox [EDITED] [duplicate]
- Send notifications to custom post author when custom post is edited
- how to edit source code of specific page in wordpress?
- How i can put $_GET codes in function.php?
- Creating custom post type with custom taxonomy and custom fields programatically
- Displaying Meta-Box Data Properly
- How to code custom special page
- How to change the link on the logo at the menu?
- Accidentally deleted php code in WordPress website [closed]
- Insert PHP code in Text
- Is it possible for two WordPress plugins to share the same code base?
- what code to add to search.php
- Is there a way to programmatically pass a category to the Media Library selector?
- Allow login only for one account from one device
- How i can remove Working Functionality of my header & footer plugin from backend files but in front end plugin need to show that plugin activate
- Copying and pasting to WordPress “code editor” code via the front end and clipboard
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- Problem with MEMCACHE and Redis with wp_options
- How to generate random codes that have to be entered to access a Mailchimp form?
- out of nowhere
- How To Export User’s Custom Fields in CSV or XLSX
- admin-ajax.php 400 bad request – whats wrong with my code?
- Updating User Meta using Theme My Login with Custom Fields
- Drop down list code for sidebar
- Some code is added automatically to my site’s header – what is it?
- New theme HTML5 Support for Search in WordPress 4.4
- It possible to implement an adhoc php web application with wordpress?
- Widget Logic code for different PMP membership levels
- Blog only showing code
- why is markup routinely placed in functions in wordpress?
- Open all external links in new window – need help with the code
- echo or return? [duplicate]
- Where to put include php file?
- CSS code for “inserting a custom post divider” after each post
- Can you not edit the HTML and PHP of your WordPress without paying?
- Remove_role not working, gives “Call to undefined method stdClass::remove_role()”
- I am experiencing difficulty fulfilling client request
- Text before price on WooCom
- What’s wrong in the WordPress Meta Box Generator code?
- how to create twitter card without plugin in wordpress website?