Ben Lobaugh Online

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

Find and update WordPress posts with comments older than NNN days

I have a use case where I need to disable comments on posts in WordPress where the last comment was more than one year, or 365 days, ago.

Posts can be found with this query:

SELECT p.ID, p.post_title, p.post_date, p.comment_status, p.`ping_status`
FROM wp_posts AS p
     SELECT c.comment_post_ID
     FROM wp_comments AS c
     WHERE DATEDIFF( curdate(), c.comment_date ) <= 365

The outer query takes the inner query as the search parameter. The inner query is finding the latest comment for each post based on the number in the WHERE condition. 365 represents 365 days, or 1 year.

Therefore, this query is getting the latest comment for post where the comment is less than 1 year old.

Now let’s say you need to update the posts to disable comments. The goal is to disable commenting for all posts that have not had a comment within the last year. It can be accomplished with the following:

UPDATE wp_posts
SET comment_status='closed', ping_status='closed'
		SELECT c.comment_post_ID
		FROM wp_comments AS c
		WHERE DATEDIFF( curdate(), c.comment_date ) >= 365

Here again the number 365 represents the number of days.

Check the posts and you should see the comments have been closed.

What I have been up to Q1 2018

People are noticing!
Noticing that I have not posted on this site in a couple months.

Yes I am still around! Kicking butt and taking names.
I have been working hard to make my 2018 Vision be, and continue to be, a reality.

How’s it going so far? Nailing It!

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 2
Masterminds 3
Coaching Coaching: 27 sessions with 6 clients for 41+ hours!

Just today in fact I spoke for Simply Beautiful Tiny Homes LLC during a Real Estate Investors Association of Washington training day on Team Building and Communication.

There is a lot more coming down the line too! For example, I currently have 528 mastermind sessions planned with clients. Some of those sessions are part of a year long daily growth session.

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 2
Pre-launch 1
Self-sustaining 2

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

This is the most exciting vision for results!

Alix and I have been growing together exponentially. The last two years have been very busy for us personally and combined. As you can see from above I have a lot going on, so does Alix. She is currently working as a NICU nurse, finishing a Masters in Nursing Education, and running her own clothing business.

At the beginning of the year we read the book How to Improve Your Marriage Without Talking About It. In the book, the authors share the differences between men and women and how we relate to our environment and each other. It walks the reader through the physiological and phycological differences between men and women and provides clear examples on how a situation affects each sex with proven scientific research. This book has opened our eyes to truly be able to see from the other persons perspective and quickly reestablish connection. I 100% believe every dating and married couple should read this book.  If you have not read it already please please please make it top on your list to get a copy and read it. I would love to hear how it changes your life. Drop me a message on the contact form and lets chat!

Vision: Live a slow paced life

Though it may not sound like it from the above I am actually accomplishing this vision too! Sure I have a lot on my plate but it is on my schedule. I have been using Pareto’s 80/20 Rule to analyze and aggressively cut out activities that fall into the 80% category. This has resulted in a much calmer, more peaceful state of being. It has allowed me to expend more time and dedicated energy in communing with Alix and close friends, as well as dialing in the areas of my life that move me towards my goals. As a bonus, I have been able to read again. I set a goal of 80 books this year and as of this writing have finished 18!

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

Finally, a standing desk on the boat!

I have had standing desks for years. In fact, I recently posted a photo I found of the standing desk I had at our Lake City house. When we moved onto the boat I was bummed that there was no area that was both compact and out of the way enough for a standing desk. A couple weeks ago I accidentally ran across the solution!

What I have set up now is a monitor mount with a tray on the arm instead of a monitor. It has been working great! The only major issue I have run across is the monitor height. Because I am using the built in laptop monitor I am looking down, which hurts the upper back after a while. Thinking now about getting a small external monitor to mount similarly above the laptop.

Lake City Desk – final

For some reason people often ask what my desk looks like. I even have an entire category dedicated just to desk photos. Unfortunately I had not had a picture of the final desk I had in the Lake City house, which was one of my favorites. I found one! This is my desk circa Jan 13, 2016.

It is a standing desk, built from a (musical) keyboard stand and a bass guitar case. It was rather enjoyable to use.

Penny’s 2017-2018 boat topper

Winter is here again, that mean rain and winds. Last year we created a canvas top with velcro sewn into it that kept the back of the boat mostly dry, but did allow the wind to whip through.

This year I added port side and rear windows. For 2 reasons: 1) It lets more light in than a solid canvas (duh). 2) The port side is a wind block.

Specifically, I changed it this year to have a side wall because during storms the wind comes from the South. Our rear port side is exposed to the South, meaning the winds hit us directly. The walls stop the wind and any sideways rain from getting into the boat. So far it has worked perfectly.

This top is definitely not elegant in any way. It is essentially a huge tarp with a corner sewn into it. It is nowhere near the elegant canvas work on other boats around me, but it is significantly cheaper than having it professionally made. That said, if we live here again next winter I think we will spring for a professional canvas. It will enclose all 4 sides and the flybridge, which will dramatically increase our dry living space.

Page 1 of 147

Powered by WordPress & Drip City Coffee