wp_insert_post not working for custom post type?
Try add the second parameter like: $post_id = wp_insert_post( $new_post, true ); If it still won’t work, please var_dump the $post_id and paste here.
Try add the second parameter like: $post_id = wp_insert_post( $new_post, true ); If it still won’t work, please var_dump the $post_id and paste here.
If all you do is update ACF fields with your form, why not use the built-in function to generate the form? Create a new ACF field for the images, or simply use the Gallery field type, then display the form using acf_form: <?php acf_form(array( ‘post_id’ => ‘new_post’, ‘new_post’ => array( ‘post_type’ => ‘vendre’, ‘post_status’ => … Read more
So If I understand correctly you are creating a custom import plugin to wordpress outside the normal wordpress scope. Therefore you don’t have access to the functions inside .pluggable.php like is_user_logged_in you can redefine them in your plugin or you can just use require_once( ABSPATH . “wp-includes/pluggable.php” ); You will also not be able to … Read more
If the slug exsit WordPress will add a number to the end. For example if you had two post named “test” you would get “test” and “test-1” Hope that helps
See my comments above, but part of the problem is that you are checking that $_POST[‘action’] == “new_post” In the example you’ve given you have commented out the hidden ‘action’ field; which, in any case is set to post not new-post. I believe you a trying to check the nonce… To do that (following the … Read more
Change ‘name’ to something else. Because name is a reserved keyword in WordPress universe. Check this and look for ‘name’ here.
To fire a hook you can use following functions: do_action – executes a hook created by add_action. do_action_ref_array – execute functions hooked on a specific action hook, specifying arguments in an array. This function is identical to do_action, but the arguments passed to the functions hooked to $tag are supplied using an array. If you … Read more
With that function in functions.php it is going to run on every page load and every time it runs it is going to insert a post for every user in your database. It isn’t an infinite loop. You are just running it all the time. You need to run that one time and one time … Read more
You can try to remove the filter remove_filter(‘the_content’, ‘some_func’); and add it again with your customized version of some_func() called some_func_mod(): add_filter(‘the_content’, ‘some_func_mod’);
Did some profiling, it was the 5k+ queries being stored in the $wpdb->queries array.