WordPress (admin) posts search GET request filter

I wrote up a plugin that adds a column to the posts, page table (list) in the WordPress Admin panel.

Each row has additional input fields (checkboxes) - allow_comments, allow_pings. These checkboxes are used to update comment_status and ping_status with tick on checkbox via AJAX call.

Problem begins when I have big load of posts and do a search in the search field, all of my input fields (checkboxes) gets added to the search and if there's a lot then the request URI becomes too long to send and apache errors with 50x Error.

How can I prevent WordPress from including my input fields in the search request?

At the moment I disable on search submit checkboxes to avoid them to be added to the GET Reqest, but maybe there is a better solution?

/**
 * Show checkbox Allow pings for post type
 * @param $column_name
 */
function jepc_add_pings_column_table_content($column_name) {
    global $post;
    if ($column_name == 'allow_pings') {
        echo "input class=\"editable_ping_comment prevent-submit\" data-type=\"ping\" name=\"allow_ping[]\" type=\"checkbox\" value=\"" . $post-ID . "\"" . ($post-ping_status == 'open' ? ' checked="checked"' : '') . " /";
        echo "div id=\"result_ping_" . $post-ID . "\" style=\"display: none;\"" . __('Updating...', 'jepc') . "/div";
    }
}

add_action('manage_posts_custom_column', 'jepc_add_pings_column_table_content', 10, 2);

Javascript

/**
 * Disabling checkboxes not to be includes in search get request
 */
$('#posts-filter').submit( function() {
    $('.prevent-submit').attr('disabled', true);
});

Topic request-filter input wp-admin Wordpress search

Category Web


    function getPostsByCategorySlug(slug) {
  return site.categories().slug( slug )
    .then(function( matchingCats ) {
      // matchingCats will be an array of the one post that matches
      // the provided slug
      if ( ! matchingCats.length ) {
        throw new Error( `No category found for slug "${slug}"` );
      }
      var catID = matchingCats[ 0 ].id;
      return site.posts().categories(catID);
    });
}

getPostsByCategorySlug( 'some-category-slug' )
  .then(function( posts ) {
    // Do something with your posts
  })
  .catch(function( err ) {
    // Could not get categories
    console.error(err);
  });

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.