Monthly Archives: March 2012

Ways to Increase Max File Upload Size and Execution TIme

Since I originally posted this, I have assisted several persons with this problem.  One additional thing I have found that will sometimes work is to contact the hosting service support.  A good support group can easily fix this for you.

Here is a list of things that I tried on a couple of my sites to increase the file upload size and the script execution time.

Initial File Upload Size: 2M

Initial Execution Time: 30 sec

The first thing I tried was adding some lines to functions.php.

Note: you must be careful when editing functions.php because any mistakes will cause your site to become unusable and you must use ftp to correct the error.

// Increase max upload file size and execution time
@ini_set( 'upload_max_size' , '20M' );
@ini_set( 'post_max_size', '20M');
@ini_set( 'max_execution_time', '300' );

This did not work.

Next, I tried an addition to wp-config.php.

define('WP_MEMORY_LIMIT', '20M');

Did not work.

I found several reports that adding the following to .htaccess would work:

php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value memory_limit 20M
php_value max_execution_time 300

I don’t know if I added the lines incorrectly or not, but it caused internal server errors.

Finally, I created two files, php.ini and php5.ini, with the following lines
and added both files to the wp-admin folder. WORKED!!

upload_max_filesize = 20M
; Maximum size of POST data that PHP will accept.
post_max_size = 20M
max_execution_time = 300

If none of these things work for you, your hosting service support team might increase the limits for you.

Make WordPress More Link Open in a New Window

If you would like your WordPress ‘more’ tag link to open a new window, you can use this filter in your functions.php.

The ‘target=”_blank”‘ method has been deprecated in XHTML, so we are forced to use the onclick and onkeypress methods.


// More tag link open in new window
function more_tag_new_window($link) {
   preg_match('/^(.+)?<a (.*)$/',$link,$matches);
   if ($matches) {
      $link = $matches[1] . '<a '
         . '<a onclick="window.open(this.href); return false;" '
         . 'onkeypress="window.open(this.href); return false;" '
         . preg_replace('/#more-\d+/','',$matches[2]); // Remove the jump link
   }
   return $link;
}
add_filter('the_content_more_link','more_tag_new_window');

Show Latest Post From Each of Specified Categories

The Code below illustrates how to select the latest Post from each of a list of categories.
Continue reading

List Author Information

Several persons have requested code to list information about Post authors. The sample code below illustrates one technique.
Continue reading