Tag Info

New answers tagged


After two days looking for the solution and fighting with the code, I found the solution: As I suspected, the problem was reading the file ($image_data = file_get_contents($image);). The first error was not included in the form enctype =" multipart / form-data " to send files and data simultaneously. The second error was that images are not loaded by ...


WordPress check if post exist by title function wp_exist_post_by_title( $title ) { global $wpdb; $return = $wpdb->get_row( "SELECT ID FROM wp_posts WHERE post_title = '" . $title . "' && post_status = 'publish' && post_type = 'post' ", 'ARRAY_N' ); if( empty( $return ) ) { return false; } else { return ...


sampler: if( !get_page_by_path('mypageslug',OBJECT,'post') ){ //your codes }


I've found that the update_field() function actually does the job for me, I don't know if it's been updated since to make that happen. All you have to watch out for is if you have a single choice (select) field or one that allows multiple selections - you need to pass through an array of taxonomy ID's if it's multiples, basically. In example: $field_key = ...


You can use sessions to store the data. There is a plugin also for that which I have used in the past and it works quite good. https://wordpress.org/plugins/wp-session-manager/


I found a working solution. This handles the uploaded files by attaching them to the post and display them in the loop. Still no featured image is set. if ( $_FILES ) { foreach ( $_FILES as $file => $array ) { $newupload = insert_attachment( $file, $pid_buy ); } } function insert_attachment( $file_handler, $post_id, $setthumb='false' ) { ...


Use update_post_meta(), because if the meta key already exists add_post_meta() will do nothing if $unique is true and otherwise won't update neither, while update_post_meta(), well, it will update the value of a existing field or create it, if it doesn't exist yet.

Top 50 recent answers are included