Site icon Hip-Hop Website Design and Development

Get the chosen posts IDs to make use of in bulk edit AJAX name

The WordPress codex for bulk_edit_custom_box, together with this bulk edit instance use the next piece of JavaScript to create an array of chosen publish IDs to ship with the AJAX name that updates the posts.

$bulk_row.discover( '#bulk-titles' ).kids().every( operate() {
    $post_ids.push( $( this ).attr( 'id' ).substitute( /^(ttle)/i, '' ) );
});

The complete code surrounding this snippet is under.

My record tables have enter fields for meta values, and the inline fast edit works efficiently, however bulk edit fails. When debugging I discovered the $post_ids array is empty as a result of there aren’t any parts on my web page with the ID #bulk-titles.

So my query, the place do the #bulk-titles parts come from and why would my web page not have them?

$( '#bulk_edit' ).dwell( 'click on', operate() {

    // outline the majority edit row
    var $bulk_row = $( '#bulk-edit' );

    // get the chosen publish ids which are being edited
    var $post_ids = new Array();

    $bulk_row.discover( '#bulk-titles' ).kids().every( operate() {
        $post_ids.push( $( this ).attr( 'id' ).substitute( /^(ttle)/i, '' ) );
    });

    // get the customized fields
    var $item_thickness = $bulk_row.discover( 'enter[name="item_thickness"]' ).val();
    var $item_width = $bulk_row.discover( 'enter[name="item_width"]' ).val();
    var $item_length = $bulk_row.discover( 'enter[name="item_length"]' ).val();

    // save the information
    $.ajax({
        url: ajaxurl, // this can be a variable that WordPress has already outlined for us
        sort: 'POST',
        async: false,
        cache: false,
        information: {
            motion: 'manage_wp_posts_using_bulk_quick_save_bulk_edit', // that is the title of our WP AJAX operate that we'll arrange subsequent
            post_ids: $post_ids, // and these are the two parameters we're passing to our operate
            item_thickness: $item_thickness,
            item_width: $item_width,
            item_length: $item_length
        }
    });

});