kses_remove_filters();
$new_id = wp_insert_post($post_arr, true);
kses_init_filters();
if (is_wp_error($new_id)) {
$this->write_log("error occurred in wordpress post entry: " . $new_id->get_error_message() . " " . $new_id->get_error_code(), true);
return;
}
if($url) update_post_meta($new_id, 'source_link', $url);
else {
// wp_delete_post($new_id); // Move post to trash
$deleted = wp_delete_post($new_id, true); // Permanently delete post
if(! $deleted ){
$this->write_log("error deleting post entry.", true);
return;
}
}
Related Posts:
- How to display custom field in woocommerce orders in admin panel?
- Programatically add options to “add new” custom field dropdown
- Get a list of all available fields in the User Profile
- Enabling shortcodes for custom fields
- Add options to featured image
- Authors details such as social media links, emails etc → Is this Meta or something else?
- Assign category using custom field?
- Function to Download External Images to My Site
- Checked() showing up twice in custom fields
- How to use max and min values of custom fields
- Woocommerce Storefront WordPress Ignore Media Gallery Images and use External 3rd Party Host
- Customizer field value into functions.php variable
- How to display custom option field in woocommerce orders in admin panel?
- How to add a slide toggle to the Woocommerce-Layout__Activity-Panel area in the orders admin page
- What WordPress function to use to get meta value by using meta keys?
- Removing custom meta data
- Change label for registration Fields
- Custom Attachment Caption Fields
- Default Custom Field Value Automatically Update
- WordPress function saves a post twice and updates all posts
- ACF not showing
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- How to get correct value from checked()?
- Prevent custom field from being updated after first publish
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Programmatically add Yoast meta description after post save
- Insert Address fields into function
- How to make custom comment fields required
- How add body_class from wp_termmeta
- How do I display a date correctly that is stored in the database as a backwards 8 digit number from Advanced Custom Fields? [closed]
- Sort and display pages with specific custom field (not tag)
- shorthand syntax for custom fields
- Fill empty custom field with other custom field
- Perform function on publish AND save (not just save)
- How to Display WooCommerce Product Price in WooCommerce Archive
- How to change text color depending on the number value (Using javascript)
- wp_set_object_term via js btn frontend
- Populate Product Regular Price with a calculated ACF Field Value
- How Can I Concatenate A String With One Of My Custom Field Value Before Saving The Post?
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- Create New User Custom Field not Saving
- Creating a “Related Meta” type field?
- How would I correctly implement a new if statement in a child functions file?
- Hide empty custom field
- How To Show Shortcodes In WordPress Custom Fields?
- How to echo the translated custom field?
- How to add function to custom fields when page/post has a password?
- How to exclude posts with empty and non-existent relational custom field with meta_query?
- Post date on Custom field
- Dynamically generated Navigation Diagram using Custom Fields
- Define an extra field for all pages (with no plugin?)
- update_post_meta not working in function
- Adding custom field in menu options [duplicate]
- How to display data from custom fields in my custom shortcode?
- Syling Custom Fields echo’s from from functions.php
- Add custom fields after post/page title
- Adding and updating repeating custom field meta data
- Change Post status based on custom field date +1 day
- How to redirect to post if search results only returns one post
- Overriding core functions in child theme
- Should I ask a theme developer to use locate_template rather than require_once
- Customized wp_new_user_notification
- How to add an anonymous function in wordpress hooks by removing create_function
- Changing post category from dropdown
- How to update feed only 2-3 times a week (for Feedburner email)?
- Fatal error when trying to get admin email on contact form
- Is it good practice to use wpdb->query() function?
- How to properly add NPM packages and integrate them in WordPress?
- wp_enqueue_script add integrity parameter
- change in form-checkout.php by using code in functions.php
- List child pages of specific page using shortcode
- Register vendor JS/CSS only on pages that require them?
- Passing the custom field values in the wp_get_current_user array function
- How can I make a widget shortcode to control all the widgets?
- admin-ajax.php + load-scripts.php hanging for minutes
- Add a jQuery Function
- append to existing parent theme function
- How do I change a parent theme’s function through the child theme?
- Dropline menus — seperators between children only?
- 404 when enqueue_script using plugin_url
- WP Customizer API loaded into functions.php
- the_widget() inside functions.php
- How Can I add a menu to the theme from withen the function.php file
- Load templates, pass arguments, and render output from functions.php
- WordPress Lite/Light
- Is_Page doesnt detect my page
- Problems adding a new field to product in cart
- Function for Sticky Post on Categories causes issues with 404 behavior
- Store custom field’s multiple values in one user meta key
- Get value of pre-populated Gravity forms field as variable in my function
- Changing the color of post title [closed]
- Create html from function
- Admin Panel errors because of functions.php
- WordPress not performing direct update
- Using Output from one Function and calling it into another
- How to add a class and title attribute to the link generated by next/previous post
- “Headers already sent” while trying to add a CSS file to my login page?
- Notice: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in ….functions.php on line 73
- How to sort a non-meta field in the User Admin Panel?
- Remove Actions/Filters added via Anonymous Functions