Basic Breadcrumbs

Recently we made a site that needed breadcrumbs but was used as an internal portal. This means it didn’t need any SEO stuff so the standard Yoast breadcrumbs we use seemed like overkill.

Decided to create a couple simple functions to display our breadcrumbs.

By sticking those two functions in your functions.php file and then calling jb_breadcrumbs() wherever you want to display these breadcrumbs you should be all set.

ACF Convert Old PHP fields to JSON

Back in the day, if you wanted to make sure you could keep your environments in sync (and you couldn’t just be moving the database around) you had to use PHP to build and update your ACF forms. It was gross.

Nowadays you can just work with the ACF fields in the admin like normal and ACF will AUTOMAGICALLY build a json form you can use to sync your different environments.

You do need to set this up a little bit, so stick this in your functions.php file to get started.

Now the tricker part is going to be converting your old PHP.

I just setup a script like the one below and ran it once. This script is taken from David Egan’s site.

All you need to do now is copy the output from this script into it’s own file (or you could just have PHP write that file for you) and save it as a .json.

IMPORTANT NOTE: At this point this json file probably wont work. I had to go through the file and double quote all of the keys and fix up some other formatting issues. This was 99% completed by just doing a single find and replace in Visual Studio Code. Regex: “\s\w+:” This should find MOST of your keys and correctly format them so ACF can import them. This wont work PERFECTLY so you will need to scan your file to make sure everything is formatted right, but it will get you 99% of the way there.

Good Luck!


Show Post Date Instead of Freshness

BBPress shows the “Freshness” of a post by default. This is fine and will work for most people, but some clients want to show the actual date of a forum post.

Here is the code for that.

Thanks to user Robin who posted this function to the BBPress forums here:

I modified it slightly since it wasn’t working quite right in my testing.

ACF Repeater Field Meta Queries

In order to use a meta query to find a value of a post’s repeater field we need to make sure we hook into “posts_where” and swap out a “=” for a “LIKE” so we can find our correct meta keys.

Here is the example code for that.

Now we can just add a meta query to our WP Query args and search our repeater fields like so.


Set Custom Facebook Image in Yoast

Display a custom featured image while using the Yoast WP SEO plugin.


A Better Media Sideload Image

media_sideload_image is a WordPress function I have had to use countless times to upload attachments based on a provided URL. Often from Google Maps, but sometimes just from import scripts pointing to a URL. It has always worked well enough, but it has a couple of issues. The main problem is the lack of an ability to provide a filename separate from the image basename. This was especially ugly when generating static Google Maps…especially after Google Started requiring API keys…which WOULD BE SAVED AS PART THE FILE NAME!!!! Anyway, I looked around for a bit and found a really great solution on WordPress Stack Exchange from user Somatic.

It is a fairly large function so I’ll just provide the link:

Trust me, if you want to use media_sideload_image, use Somatic’s function instead.