Tag Info

New answers tagged


I find out the problem and the solution. I debugged the "wp_set_object_terms" by using "is_wp_error" and I got "Invalid Taxonomy" message, then I realized that when the posts was being created that term didn't exists. So I change the hook to "init" in the programmatically_create_post() function, and voila! Below this line the code working: <?php // ...


Here is an example. I've tried to explain each process happening in each line. I hope this code can easily explain you how this is working. <?php //creating a blank array to store the inserted terms ids $terms = array(); //inserting the term "Kathmandu" in a custom taxonomy "region" $tax_insert_id = wp_insert_term('Kathmandu','region' ); //if the term ...


Your current code should be correctly creating the post inside your Products post type. You're missing the bit that updates the post meta holding the image. Assuming the meta_key is product_image, then running this on success should do: update_post_meta( $pid, 'product_image', $attachment_id ); on a side note: don't forget to run ...


For those who would know : $upload_dir = wp_upload_dir(); $image_data = file_get_contents($image_url); $filename = basename($image_url); if(wp_mkdir_p($upload_dir['path'])) $file = $upload_dir['path'] . '/' . $filename; else $file = $upload_dir['basedir'] . '/' . $filename; file_put_contents($file, $image_data); $wp_filetype = ...


Why not just use Gravity Forms with ACF. It does exactly what you're suggesting -- and I've used it a number of times on client sites with great success.


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', ...


Use 'tags_input' instead of 'post_tags'. See here in the notes: http://codex.wordpress.org/Function_Reference/wp_insert_post You could use wp_set_post_tags() function: http://codex.wordpress.org/Function_Reference/wp_set_post_tags

Top 50 recent answers are included