Insert Post using Ajax

What says the error log? Is that the complete content of form-process.php? When it is so, then the problem might be, that the function wp_insert_post() is not defined, because the WordPress core was not loaded. Therefore WordPress has an AJAX-API. Here’s an example on how to use that API on server side: add_action( ‘admin_ajax_your_form_action’, ‘wpse_126886_ajax_handler’ … Read more

How to insert custom function into wp_insert_post

See those two hooks in the hacked Core code you posted? do_action(‘save_post’, $post_ID, $post); do_action(‘wp_insert_post’, $post_ID, $post); Those are what you need to use to do this right. function run_on_update_post($post_ID, $post) { var_dump($post_ID, $post); // debug include ‘../push/send_message.php’; sendNotification($post[‘post_title’],$post[‘guid’]); return $post_ID; } add_action(‘save_post’, ‘run_on_update_post’, 1, 2); save_post runs every time the post is saved. I … Read more

XMLRPC Avoid duplicate content

Since you add a reference to my previous answer, let me share how I tested it: Setup on site A – XML-RPC Client include_once( ABSPATH . WPINC . ‘/class-IXR.php’ ); include_once( ABSPATH . WPINC . ‘/class-wp-http-ixr-client.php’ ); $client = new WP_HTTP_IXR_CLIENT( ‘http://example.tld/xmlrpc.php’ ); // <– Change! $client->debug = true; $result = $client->query( ‘wp.newPost’, [ 0, … Read more

Prevent duplicate posts in wp_insert_post using custom fields

To save the link in the post meta you can use update_post_meta like this for example: $url = “http://sample.com/entertainment/default.aspx?tabid=2305&conid=102950” $my_post = array( ‘post_title’ => “$title”, ‘post_content’ => “$content”, ‘post_status’ => ‘draft’, ‘post_author’ => 1, ‘post_category’ => array(1), ); $post_id = wp_insert_post( $my_post ); update_post_meta($post_id,’source_link’,$url); and to prevent the insertion add a simple conditional check: $args … Read more

Speeding Up Bulk Post Creation – wp_insert_post & update_post_meta

Siteground has WP-CLI installed and when you have WooCommerce installed it adds its own set of WP-CLI commands. See this: https://github.com/woocommerce/woocommerce/wiki/WC-CLI-Overview With this your solution would be cleaner as it would go though WC’s API. Maybe you can also check for ideas how WC does it. I remember in the add/edit product UI there was … Read more

How to prevent duplicate slugs for wp_insert_post?

If you use wp_insert_post, it should calculate a unique post slug for you. If you don’t use wp_insert_post, try using wp_unique_post_slug. If neither of those are working for you, you could simple try appending -page or to the new page’s post_name (slug) before inserting it. WordPress does its uniqueness check on post slugs at application … Read more

How can I stop wp_update_post messing up HTML example code?

It was https://wordpress.org/plugins/syntaxhighlighter/ plugin’s fault. There are some functions in it that have something to do with this, namely encode_shortcode_contents_slashed_noquickedit, encode_shortcode_contents_callback. Now I replaced it to https://wordpress.org/plugins/crayon-syntax-highlighter/ but by the time I confirmed it was the other plugin’s fault I had already written a solution. function wpse190396_insert_post_data($data, $postarr){ if($postarr[‘filter’] == ‘db’ && ($data[‘post_type’] == ‘fix’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)