Query data after an Ajax insert

The function wp_insert_post() returns the post ID on success or the value 0 on error. Your PHP function should look like this : function save_enquiry_form_action() { $args = [ // Your postdata… ]; $is_post_inserted = wp_insert_post($args); if( !empty($is_post_inserted) ) { wp_send_json_success([ ‘post_id’ => $is_post_inserted, ‘post_title’ => get_the_title( $is_post_inserted ), ]); } else { wp_send_json_error(); } … Read more

Launch Media Library for specific MU site

I asked this in the WP Contributors Slack and was pointed towards this code that allows you to specify the ID of the media library you want to pull from. https://github.com/humanmade/network-media-library This doesn’t exactly do what I want, it sets a single media library for everysite to use, rather than a specific site on command.

Add class to oEmbed video from within post editor?

One idea for the shortcode version, would be to add the custom class via the the native shortcode: then you could add it to your custom wrapper with: add_filter( ’embed_oembed_html’, function ( $html, $url, $attr, $post_ID) { return sprintf( ‘<figure class=”video-container %s”>%s</figure>’, isset( $attr[‘class’] ) ? esc_attr( $attr[‘class’] ) : ”, $html ); }, 10, … Read more

admin notice on Insert Media popup screen

I’m unaware of any hooks that tap in in the pop up, but there might be. If not, you could use some jQuery to put your message on the pop-up when Add Media is clicked. I was able to with the following: add_action(‘admin_head’,’myplugin_add_media_popup_notice’); function myplugin_add_media_popup_notice() { ?> <script> jQuery(window).load(function() { // the MEDIA buttons you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)