Ben Lobaugh Online

I think, therefore I am. I am, therefore I sail

Find total number of post records on a WordPress Multisite in MySQL

I was recently asked for the total number of posts on a WordPress website. Normally as simple as looking at the number in the dashboard, however in this instance the WordPress install was a Multisite with nearly 100 sites. That would have taken far too long to do manually, but what about having MySQL do the heavy lifting for me?

The information_schema database contains data about every database and table on the server. One of the metrics it stores is the count of rows in a table. We can use that to extrapolate roughly how many entries are in all the posts tables combined. This is not an exact science, however it will get you close to the real numbers. I argue that it will typically be “close enough” on larger installs, such as the one I was looking at.

In the following query, just replace the database name with your database and run it.

SELECT SUM( table_rows )
FROM information_schema.TABLES 
WHERE 
	table_schema = "{{YOUR_DATABASE_NAME}}" 
	AND table_name LIKE '%_posts';

End Q2 2018 Update

There has been a lot going on since my Q1 Update! Still working hard to make my 2018 Vision be, and continue to be, a reality.

How’s it going so far? Pretty great! There have been some setbacks, but much more positive forward motion than backward :).

Lets go through the four vision statements…

Vision: Become a topnotch, well respected communicator and coach

To date I have completed/am currently doing:

Speaking Engagements 4
Masterminds 5
Coaching Over 60 hours!

There are two masterminds currently running, and I have plans to start another in September.

Within a week I will have another coaching clients.

I have several team building training sessions in planning phase currently.

In the final planning phase is a leadership networking group.

Vision: Let my money make me money, not me making money

This is my second most actively worked vision, after the next vision which involves my relationship with my wife.

To date I am actively working with startups (new businesses) in the following categories:

In planning phase 1
Pre-launch 2
Self-sustaining 0
Flops 0

The business I was most excited about flopped, however others are in the works! Also currently working on a multifamily real estate deal.

Vision: Build an ever improving relationship with my wife that others coming behind can model after

This is going great! I feel that Alix and I have never been more in sync. She graduated with her masters this year and we are looking toward the next phase of life. More will come on that in the next quarter.

Vision: Live a slow paced life

I have cut a lot out of my life. I am able to enjoy sailing and business building a lot more because of it. Life is still busy but it is a different type of busy. It feels slower because the busy now is of my choosing and timing.

Life is good!
I expect it only to continue getting better!

Copy data from one Google Drive to another domain

Transferring data from one Google account to another is typically as easy as sharing the files with another user and making them owner. There is a caveat though, you have to be on the same domain or GSuite account. Transferring ownership from your business account to your personal account is “not possible”.

I found myself in just such a situation. I had a single folder called Personal that I kept all my personal files in. After scouring the interwebs I found a script called Drive Migrator.

Drive Migrator does not actually move files between accounts. Instead it makes duplicate copies. If you need the data removed from the old account you will have to remove it yourself.

Here is how it works:

  • Login to the Google Drive you want to migrate. Share the folder you wish to migrate with the new Google account.
  • Visit the Drive Migrator script. Login with the account you are migrating to.
  • Select the shared folder that you wish to migrate from. This is where it is handy if everything you want is in a single folder, like the Personal folder I had.
  • Click COPY!
  • Pour yourself a scotch and kick back to wait for the migrator to do its thing.

The script could take a while to run. While it is running you will find a spreadsheet listing the progress. When it completes you will have a folder titles “backup-*” in the root of the target Google Drive. It should contain all the files from the other account.

Double check the contents of the new folder. At this point it should be safe to delete the old folder.

The brown crusty joys of boat ownership

Cruisers have a saying, “Sailboat cruising is simply boat repair in exotic places.” That may be slightly tongue-in-cheek but boy what I wouldn’t give to be in an exotic place right now.

This time last year I was reinstalling Billabong’s motor. Unfortunately the shaft seal failed shortly after and became progressively worse over the summer. To make matters worse, the salt water was spraying all over my freshly rebuilt and painted motor. It ate right through the paint and rusted up the sides of the motor. Now I get to clean it all up….again…..

Run a wp-cli command across the network

Need to run a wp-cli command across a network of WordPress sites?

Here is an example of how to add/update an option on every site on the network using wp-cli.

wp site list --field=url | xargs -n1 -I % wp --url=% option update my_option my_value

This is really two commands in one. Lets break them down:

wp site list --field=url

This command will get a list of all the sites on the network. The output is a list of the urls for the given site. Passing the url to a command on a network chooses the site to run the command on.

xargs -n1 -I % wp --url=% option update my_option my_value

Here is the kicker. This command takes the output of the previous command into xargs. Xargs then run the new wp command with each site’s url in it.

Page 1 of 148

Powered by WordPress & Drip City Coffee