How to bulk delete posts in WordPress with MySQL

mysqlUsually deleting several posts at once is not a problem thanks to the bulk delete options in WordPress. Those queries however rely on a single delete each, initiated by PHP loop. That’s fine if you’re deleting up to about 100 posts at a time.

But it’s not when you have thousands of posts to delete. I’ve come across installations with hundreds of thousands of posts which have often been created automatically – and there comes the time when you need to clean things up and prune that massive database.

Deleting 100.000 posts is impossible from within WordPress: it puts a huge load on your server, it takes forever, and besides WordPress will time out after about 200 posts.

The solution: a dedicated SQL query.

Sounds scary I know – let’s go through it step by step in this article.

Read more

Say hello to The WP Guru Podcast

Apple_Podcast_logo

This week I finally had a chance to prepare The WP Guru Podcast for you!

Get all my past, present and future screencasts delivered for free and automatically.

I’ve been planning this for years, and even though relatively simple to setup it took a bit of organisational efforts behind the scenes to make it happen. What this means is that when I record a screencast, you can now receive it via your favourite Podcast Catcher (such as iTunes).

Read more

How to run WordPress on your Laptop

In this new Podcast Season I will start things off by showing you how to run WordPress on your laptop. I will explain this on a Mac, but the process is very similar (if not identical) on a PC. All you need is an installer that gives you Apache, MySQL and PHP on your local … Read more

How to loop through every element in an NSArray

We can use something called Fast Enumeration for this, using a modified for loop: // build an array NSArray *myArray = [[NSArray alloc]initWithObjects:@”One”, @”Two”, @”Three”, @”Four”, nil]; // loop through every element (dynamic typing) for (id tempObject in myArray) { NSLog(@”Single element: %@”, tempObject); } You don’t have to use dynamic typing if you know […]

How to generate a random number in iOS

We can use the C function rand() for this: int i = rand()%10+1; NSLog(@”Random Number: %i”, i); This generates an integer between 1 and 10. Alternatively you can use the arc4random function: int i = arc4random() % 10; NSLog(@”Random Number: %i”, i); This will generate a random number between 0 and 9. One thing of […]

How to read the contents of a text file into an NSString

Imagine we had a file called myfile.txt which is a standard text file. On each line we have a new item we’d like to read so that our app can do something with it. Here’s how we do that: // get a reference to our file NSString *myPath = [[NSBundle mainBundle]pathForResource:@”myfile” ofType:@”txt”]; // read the […]