9 days in.
9 days in.
I worked from home today since the kids are now out of school and the wife still had to work.
At some point mid-day, I got the inkling to go work outside on the patio since it wasn’t as hot as it has been. Sure, it’s summer in Arizona… but I’ve lived here most of my life. I could handle a little heat.
I made it 3 minutes before coming back inside.
If you are a WordPress user that takes advantage of custom fields and WP-CLI… this may interest you.
Let’s say you’re using ACF field groups on posts in a certain category. You have a new custom field with a default value you’ve added to that field group. You’ve already modified the template to conditionally show a piece of UI based on that field value. Finally, you realize that now you’re going to have to open each post in the editor, one at a time, to save it in order to get that field value set.
Or… maybe there’s a way to script it?
In my situation, I only have about ten posts that need this treatment, but if I was looking at manually updating each post to include that new default value across hundreds of posts… /shudder
I decided to research & teach myself the steps I’d need to work through if I ever find myself in that situation.
ACF field values are stored in the
There are actually two rows in post_meta. One is the actual value. The other is a reference.
wp post update 4045 --kjzz_has_audio=1 --_kjzz_has_audio=field_59038b5c9457b
Ok, that’s a good start.
Thankfully, in my situation, all the posts I need to affect belong to a specific category. I can grab a list of the post IDs with this:
wp post list --category_name=category-slug --format=ids
So, now I need to combine the two.
Like most situations in life, I can’t be the first person to be in this boat. Someone has to have written about this in the past, right?
And this is what I ended up with:
for id in $(wp post list --category_name=arizona-business --fields=ID --format=ids); do wp post update $id --kjzz_has_audio=1 --_kjzz_has_audio=field_59038b5c9457b; done
After inspecting a few of the records in Sequel Pro, it looked like the ones that already had those custom fields were ‘updated’ (to the same value), but the ones that didn’t have those custom fields yet did not actually get new meta added.
Looks like we’re actually going to need
wp post meta and we’ll need to update/add each meta key/value individually.
for id in $(wp post list --category_name=arizona-business --fields=ID --format=ids); do wp post meta update $id kjzz_has_audio 1; done
for id in $(wp post list --category_name=arizona-business --fields=ID --format=ids); do wp post meta update $id _kjzz_has_audio field_59038b5c9457b; done
… Now I’m wondering if I could have used:
for id in $(wp post list --category_name=arizona-business --fields=ID --format=ids); do wp post meta update $id kjzz_has_audio 1 && wp post meta update $id _kjzz_has_audio field_59038b5c9457b; done
I use a lot of browsers throughout the day.
Up until a couple days ago, that meant when testing specific things, I had to right-click a link, copy the url, then paste into the browser I wanted to test in.
With Bumpr installed and set as my default browser, it intercepts links I click and pops up a quick menu of my installed browsers[^ or a subset of them… you can configure which are available] for me to quickly choose from. It’s a tiny interruption in my normal browsing around, but it’s so worth it for the convenience it offers.
But it doesn’t stop there… it provides the same functionality with email apps. Say you have the native Mail.app configured with your work email account and some other app like Spark or Airmail setup w/ your personal account. Click on a
mailto link and Bumpr will ask you which email app you’d like to use to compose and send your message.
At my day job, I get a lot of web content that starts out in email messages or Word documents.
Sometimes it’s even spread across both.
I’m kinda glad I don’t know how many times I’ve copied that content, reassembled it, and manually massaged the HTML in WordPress1. This process isn’t hard but takes a few steps and I’ve always fantasized about automating it somehow.
In fact, earlier this morning, I received an unordered list of topics for an upcoming seminar. I copied the text from an email into iA Writer and added the dashes to each line to make it a Markdown list. I then exported that file as HTML, popped it open in Sublime Text 3 to copy the well-formed markup and paste it into WordPress. It got the job done but was still more steps than I’d like.
Someday… I’ll get something quicker figured out.
Lately, I’ve been torn between iA Writer and Bear apps. I love the simplicity of writing in Markdown and with either app, I have access to my all my notes across phone, tablet, and laptop. I keep going back and forth trying different features in each app attempting to get myself to commit to one.
I was doing a little research this afternoon and stumbled across Matthew Temple’s article comparing Ulysses and iA Writer
“… both let you write in Markdown, copy as HTML, export as …”
Wait! Copy as HTML?
I’ve gotta try this.
Sure enough. I opened that quick note from earlier w/ the markdown list, selected the text, and found Copy HTML in the menu. No exporting another file to open and copy from.
Here’s the before and after.
I’m a loyal husband.
When it comes to software… I’m apparently quite fickle.
I seem to cyclically rotate from Chrome > Firefox > Safari > Opera (and some of their developer/preview versions) as my default browser every couple months. I also tend to do the same with code editors like Sublime Text, Visual Studio Code, Atom, and others. Looking back, I’ve done it with WordPress, Ghost, and some other CMSes over the years.
Freedom to switch is a powerful thing. But I’d really be a fan of myself if I’d jot down a note in some consistent place about why I’m switching.
Someone build Switch Log or Fickle Logic or whatever you think it should be called.
(Forgive the Culver’s drive-thru sign. ;))
Looks about right: family in the center… with lots of board games. 🙂
Have you ever wondered just how much time you’ve accidentally sunk into Instagram or Facebook in one day? Or how much time your kids have actually been playing Minecraft or watching Youtube videos?
Our family found a little white box that can reveal that information and let you take control of it for better balance in your household.
Circle with Disney