A Better GForms Repeater Example

The Gravity Forms repeater field example is helpful, but has multiple issues that don’t make themselves apparent until you try to implement it.

Thankfully Giorgos Sarigiannidis has a better repeater example that solves some of the most troubling issues of the repeater field.

Here is my example of the same idea, but using a different form as the fields in the repeater. This allows the client to update the fields in the repeater themselves.

 

Gforms doesn’t have a counter system built in yet so if you want to use a counter with your repeater ( ex: Attendee #1, Attendee #2, etc… ) here is some SCSS code you can use to accomplish that.

This will look something like this:

ACF Gallery Saved to Specific Folder

Recently we had a client that wanted to make sure all of the files in one of their galleries was in a specific directory instead of the default upload/year/month directory.

Here is a simple function to make sure that happens, including updating all previous files uploaded to that gallery.

 

Search Post Title and Meta

Unfortunately when you are doing a custom query in WordPress by default you can’t search by the “s” parameter and a meta_query. A common technique was to just do two queries and merge them. That works, but it is not efficient.

User Satbir Kira over at StackOverflow posted this great solution. Simply add this function to your functions.php file and replace the “s” parameter in your custom query with a “_meta_or_title” parameter.

Here is what an example query might look like.

 

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: https://bbpress.org/forums/topic/freshness-date-format/

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