Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects

There was an associated post to this one that shed light on this answer. When registering the post type, I was not setting enough fields in the ‘supports’ array of the register_post_type. Adding author, whatdayaknow, gives me the data I’m looking for. Thanks to @milo for being on the right path! register_post_type(self::POST_TYPE, array( ‘labels’ => … Read more

wp_insert_post does not write my post_name

Gr8 job… only thing missing is the action and the timing for it to work… try this: $ins_home = array( ‘post_title’ => ‘Home’, ‘post_name’ => ‘my-home-site’, ‘post_status’ => array(‘publish’), ‘post_type’ => ‘page’, ‘comment_status’ => ‘closed’, ‘ping_status’ => ‘closed’ ); $ins_home_id = wp_insert_post($ins_home, 10, 1); $result = $wpdb->query(“SELECT wpost.post_name FROM $wpdb->posts wpost WHERE wpost.post_name=”my-home-site””); if($result < … Read more

Cropping an image before inserting into a post

I think you are good, but you don’t need to use other functions. You have all in File: wp-includes/media.php For instance, you may _wp_get_image_size_from_meta to get the image dimensions, so you don’t need to use something like this: $size = getimagesize($file); $width = $size[0]; $height = $size[1]; $mime = $size[‘mime’]; To get the image dimensions … Read more

How I upload, save and set a featured image from my frontend?

sorry this isn’t an answer but you need to sanitize that user input. Your allowing tags to be written directly into your post content which allows anyone to run javascript in both wp admin and on the front end of your site (assuming you’ll eventually print these posts). highly recommend (at minimum) strip_tags() or htmlspecialchars() … Read more

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