WordPress Tip: Specify a Primary Category using Advanced Custom Fields

acf

What WordPress custom fields should have been

I found Advanced Custom Fields (also known as ACF) about 6 months ago while working on a project for a client. They didn’t want to have to mess around with editing the Custom Fields that come native with WordPress, it just wouldn’t have worked as smoothly.

The client needed to require one image, one PDF, one year selection, and one category. The category consisted of two options, “Weekly” or “Daily”. If you’re wondering, it was a newspaper client who wanted to categorize their posts as being either a “weekly issue” or a “daily issue”. Makes sense for a newspaper!

Getting the native WordPress custom fields to play along well with files can be tricky, and probably not worth the effort, especially with a plugin like Advanced Custom Fields around.

So, enter the hero of this post, Advanced Custom Fields. I was able to set everything up with Advanced Custom Fields within about 20 minutes, and that even counts the time that I took to make various theme templates pull data from Advanced Custom Fields. The actual setup of Advanced Custom Fields took about 2 minutes.

I’ve since started using Advanced Custom Fields here at longren.io, too. Independent Publisher, the WordPress theme I’ve been using, likes to show one main category when you’re viewing a single post, even if it’s not the most relevant category. So instead of a post about WordPress having the Git category shown at the top, I can now specify which category I want to be shown. So, for a post like this, I would obviously choose WordPress as my primary category.

I’ve already added the necessary parts to my Independent Publisher child theme, and have sent a pull request to Raam Dev to get his thoughts. It’s a very easy thing to support in a theme, however, it requires that everyone using that theme use the same field name in ACF.

I named my field primary_category, since that’s exactly what it is.

Example field setup with Advanced Custom Fields

Example field setup with Advanced Custom Fields

After you’ve added your “Primary Category” custom field, you can then use the value of that field throughout your theme. I’ll have a short post later this week on exactly how you can display the primary category value in your theme. Or, if you want to know right now, you can see this pull request at GitHub.

As you can tell, Advanced Custom Fields is a beast of a plugin. I also love that Advanced Custom Fields is totally free, which is kind of amazing to me. I’ve come across many paid plugins that are nowhere near as polished and user friendly as Advanced Custom Fields.

Advanced Custom Fields doesn’t skimp on the documentation, either. Their documentation site is extremely helpful, I never once ventured away from it while getting familiar with Advanced Custom Fields for the first time.

You can download Advanced Custom Fields from the WordPress Plugin Directory, so you can also install it in just a few clicks, right from your WordPress Dashboard! Advanced Custom Fields is developed primarily by Elliot Condon, and can also be found on GitHub.

The great thing about this is that it can be applied to any theme, not just Independent Publisher. So, if you’re not using Independent Publisher, just setup Advanced Custom Fields as I described and make the necessary changes for your theme.

A follow-up post will have more details on using data from Advanced Custom Fields, no matter what theme you’re using.

Fort.js: A Modern Progress Bar for Form Completion

fortjs

Modern progress bars for your forms

Fort.js is cool. It makes adding progress bars to your forms extremely easy. It’s especially useful for signup forms, or any form where it’s nice to see how far along in the process you are.

I don’t have Fort.js in use on any public facing sites yet, but the Kegplan.io dev site has an updated signup process that makes use of Fort.js, and I love it.

Fort.js comes with four different effects: default, gradient, sections, and flash. I typically use the Sections effect, it makes it very easy to see how far along you are in the form.

I’d love Fort.js even more if changing the colors was a bit easier. Changing the progress bar colors varies depending on which effect you’re using, but it’s all documented in the README.

Fort.js and related documentation can be found on GitHub.

Receive Alerts On SSH or SFTP Logins with Papertrail

papertrail

Frustration-free log management, plus a lot more

I’ve been a huge fan of Papertrail ever since I discovered it, probably about a year ago or so. I use it mostly to monitor server logs. I currently have two servers setup to send syslog messages to Papertrail.

The Papertrail Events dashboard can be a bit overwhelming at first, but the provided search is powerful and allows you to finely control which log messages you see and which you don’t.

You can even setup saved searches to fire when a specific event occurs. For example, I have a saved search that searches for the following:
Accepted publickey for tyler

When that message shows up in Papertrail, it means that I logged in, or that someone else has logged in using my SSH key. This can be quite handy, especially if you’re a one man shop like me and are usually the only person that has SSH or SFTP access to a server.

Getting a DigitalOcean VPS added to Papertrail, especially if it’s running Debian or Ubuntu, is super easy. It just requires that you modify /etc/rsyslog.conf and add a line to the end of the file that will send a copy of the system logs to Papertrail.

Papertrail can monitor application logs, too, such as Apache httpd logs and MySQL server logs, although that takes a bit more configuration to get working properly.

If nothing else, it’s just nice having system logs aggregated in one central place, where everything is easy to search through, making it easy to find exactly what you’re looking for. If you’re an admin for one server or hundreds of servers, Papertrail could turn out to be one of your favorite tools. It’s definitely one of my favorites.

I suggest you give Papertrail a try, can’t hurt, they even have a plan that’s free forever. It’s definitely a great service for monitoring server logs.

Pretty YouTube Embeds with PrettyEmbed.js

PrettyEmbed.js

Prettier embeds for your YouTubes

PrettyEmbed.js is a jQuery plugin for making YouTube embeds look much better. It’s on GitHub, and a demo can be seen here on CodePen.

PrettyEmbed.js works with FitVid.js, but it’s not required, and comes with options like high-res preview images and advanced customization of embed options.

You can see some of the advanced customization options in the CodePen demo below. Just click the “JS” tab to see the JavaScript.

See the Pen PrettyEmbed.js Demo by Mike Zarandona (@mike-zarandona) on CodePen.

How-To: Reset WordPress Database to Default Settings

wpdb-reset

Easily Reset Your WordPress Database

WordPress Database Reset is a WordPress plugin I recently came across that will at some point prove very, very useful to me.

It’s not often that I need to reset a production WordPress database to it’s default settings, but this plugin will make the task a whole lot easier. Chris Berthe, the author, describes the plugin like this:

WordPress Database Reset is a secure and easy way to reinitialize your WordPress database back to its default settings without actually having to reinstall WordPress yourself.

I can see this being crazy useful for WordPress plugin and theme developers. We frequently need a fresh database to work with, so I’ll be adopting this plugin in my WordPress plugin and theme development workflow from here on.

WordPress Database Reset requires WordPress 3.0+ and can be installed just like any other WordPress plugin. It’s in the WordPress Plugin directory, and can also be found on GitHub.

If you’re a WordPress theme or plugin developer, you should definitely check it out.