Add an image gallery to a custom post type?

When you just have raw image files, that you want to assign to a post, wp_insert_attachment will do the job. With attachments already present in your database you can use wp_update_post to set the attachment’s post_parent. Like this: wp_update_post( array( ‘ID’ => $attachment_id, ‘post_parent’ => $parent_post_id, )); To recieve a post’s attachments you can use … Read more

Using ob_start() in plugin

No, this is not a correct use for ob_start(). You’re getting the warning because your script is outputting code before the page headers are sent – meaning you’re printing output before the html page. Without knowing what’s going on in your // other plugin code it’s difficult to say what’s happening exactly. I would guess … Read more

How do I check if my $wpdb->insert() was successful?

It returns either the number of rows inserted or false on error. Maybe you can get id of inserted recode or false if the insert fails: refer link: https://developer.wordpress.org/reference/classes/wpdb/insert/#return So you can check like below: $result_check = $wpdb->insert( $table, array(“name” => $name, “email” => $email)); if($result_check){ //successfully inserted. }else{ //something gone wrong }