Blank page when trying to change download directory

Working with wordpress 4.2.2, when I use this code in the function.php child theme to change the attachment download directory according to each message type:

function wpse_16722_type_upload_dir( $args ) {
// Get the current post_id
$id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : '' );
if( $id ) {    
   // Set the new path depends on current post_type
   $newdir = '/' . get_post_type( $id );
   $args['path']    = str_replace( $args['subdir'], '', $args['path'] ); //remove default subdir
   $args['url']     = str_replace( $args['subdir'], '', $args['url'] );      
   $args['subdir']  = $newdir;
   $args['path']   .= $newdir; 
   $args['url']    .= $newdir; 
   return $args;
   }
}
add_filter( 'upload_dir', 'wpse_16722_type_upload_dir' );

I get a blank page! there are no empty lines in the .php function, and the problem only occurs after adding this code. I really need to organize my download folder, but without a blank page. is there any solution?

+4
source share
1 answer

As stated above, you need to see a bug report. Add to the top of the wp-config.php page: php error_reporting(E_ALL); ini_set('display_errors', 1);

If this does not work, find define('WP_DEBUG', false);and set the valuetrue

wp-config err.log : @ini_set( 'log_errors', 'On' ); @ini_set( 'display_errors', 'Off' ); @ini_set( 'error_log', $_SERVER['DOCUMENT_ROOT'] . '/err.log' );

0

All Articles