1

I'm getting this error message within the dashboard or Wordpress:

Notice: Undefined index: post_type in /var/www/vhosts/dpsnet.frontier.ms/wp-content/plugins/responsive-slider/responsive-slider.php on line 594

I've not made an custom edits to the code. Can anybody help? Here is the function associated with the error:

function responsive_slider_column_order($wp_query) {

    if( is_admin() ) {

        $post_type = $wp_query->query['post_type'];

        if( $post_type == 'slides' ) {
            $wp_query->set( 'orderby', 'menu_order' );
            $wp_query->set( 'order', 'ASC' );
        }
    }   
}
Machavity
  • 30,841
  • 27
  • 92
  • 100
Drew
  • 11
  • 1
  • 2

1 Answers1

5

This error comes from within a plugin.

In case you're working on the plugin, to fix the issue you should first check for the existance of the $wp_query->query['post_type'] variable, like this:

if( isset($wp_query->query['post_type']) ) {
    $post_type = $wp_query->query['post_type'];

    if( $post_type == 'slides' ) {
        $wp_query->set( 'orderby', 'menu_order' );
        $wp_query->set( 'order', 'ASC' );
    }
}

In case you're not working on the plugin, you might want to disable the errors for the plugins and simply enable them for the themes. To do that, you can add the following snippet of code to your wp-config.php, right below the WP_DEBUG constant definition:

function ignore_plugins_errors($errno, $errstr, $errfile, $errline, $errcontext) {
    if (defined('E_STRICT') && $errno==E_STRICT) {
        return;
    }

    $error_file = str_replace('\\', '/', $errfile);
    $content_dir = str_replace('\\', '/', WP_CONTENT_DIR . '/themes');

    if (strpos($error_file, $content_dir) === false) {
        return true;
    }
    return false;
}
set_error_handler('ignore_plugins_errors');
Marin Atanasov
  • 3,266
  • 3
  • 35
  • 39