How-to split a number into equal chunks

The other day I had to iterate over a large number of items but to avoid a timeout I could only compute a certain amount at a time. So I had to split the number into equal chunks and a remainder. Here’s an easy way to determine the chunk size:

$totalNumber = 50321;
$chunkSize = 1023;

$remainder =  $totalNumber % $chunkSize;
$chunks = ($totalNumber - $remainder) / $chunkSize;

The code return the following values:
$remainder => 194
$chunks => 49

Verification: (49 * 1023) + 194 = 50321

How does it work?
In line 4 $totalNumber is divided by a modulo operator (“%” is the PHP token for modulo). The operator returns the remainder of the division (194 in this case). By subtracting this value from $totalNumber it becomes a whole number multiple of $chunks and the division with $chunkSize equals the desired number of $chunks (line 6).
Now you have the number of necessary iterations and the remaining part.

WordPress: Publishing posts in the past

There may be situations where you want to publish a post with a date in the past. On first sight WordPress does not have such a function. If you look closer you find on the page “Add new post” in the metabox “Publish” the following entry:

If you click on Edit a field appears in which you can enter the desired publishing date:

You can not only choose a date in the future but also a date in the past. After you have entered the date you should not forget to OK because otherwise the new date isn’t used when you publish the post:

If you press Publish the post will be published with the date set above:

Update: Monika Thon-Soun advised me that this practice may not be suitable if you’re focusing on search engine ranking since the subsequent entry may confuse Google et al.

Remove “by author” post section from Genesis themes

As I already wrote in How-to remove the author from your Twenty-Ten posts most blogs do not need the section “by author” since there is only one author.
By default most Genesis themes contain this section (e.g. the prose theme):

Let’s see how-to remove the author’s name from the post info. Continue reading Remove “by author” post section from Genesis themes