Get a self-hosted WordPress site for free at OpenShift is great but sometimes you need to be able to install third-party plugins and themes. That’s where services like OpenShift come in really handy.

Here’s how to use OpenShift’s free tier to setup WordPress for free.


So, through OpenShift’s free offering, you get 3 “gears” that you can use to add up to 3 applications, WordPress being an application. Thus you can add up to 3 separate WordPress sites with that free tier.

I mentioned in the video that you can use a custom domain name too. I’ll try and cover that in more detail in a future video.

Any other questions for now though, feel free to ask. 🙂

Get a self-hosted WordPress site for free at OpenShift

Displaying fields with a shortcode for CFS

I wrote a bit previously about the Custom Field Suite plugin here:

To reiterate, Custom Field Suite is a powerful, free plugin for easily creating custom fields in WordPress using an elegant graphic interface.

One problem

As amazing as this plugin (and it’s elegant interface) is, non-developers will likely struggle to display their custom fields. It requires custom PHP code.

While the plugin makes it dead simple for developers to code their custom solution, it’s not quite so easy for non-developers. So I’ve been working to simplify that.

Here’s the result so far:

With that downloaded and installed as a plugin, you’ll have a simple shortcode at your disposal:


That little shortcode will render all the fields for the currently viewed post in a list. It works with no parameters by default, but there are a bunch of options if needed:

  • exclude: a comma-delimited list of field names to exclude
  • exclude_titles: a comma-delimited list of field names for which to “not” render titles.
  • container_class: a CSS class for the container, if needed, to easily target items.
  • field_class: a CSS class for each field.
  • list_type: an option to render the fields as lists or divs; ordered, unordered or div.
  • render_post_title: true to render the title, false otherwise.
  • render_empty: true to render empty fields (fields with no value specified), false to not display them.

As an example, if you had a bunch of fields to display but wanted to hide the fields with the names, ‘id’ and ‘release_year’, you could use the shortcode like so:

[cfs-fields exclude=”id, release_year”]

Again, those options are not necessary. The shortcode will just fine on its own.

There’s a lot more I should say about it, but I hope this much info helps for those looking to easily display their fields with CFS. As I get this one more refined, I’ll get some more extensive info and a video to walk through it.

Any questions, just let me know. 🙂

Displaying fields with a shortcode for CFS

Displaying all fields with Custom Field Suite in WordPress

Custom Field Suite is a forked alternative to Advanced Custom Fields. The two work very similar so while looking for a way to render a series of fields for a post, I looked up ACF’s method and found it works great with CFS!

Here’s the ACF method:

And here’s an adjusted gist version:

As you’ll see, ACF has a get() method so you use CFS()->get() with no parameters to get all custom fields for the current post. It’ll give you an array. And you just iterate over the array and get() each field by name, then render it.

Displaying all fields with Custom Field Suite in WordPress

Finding hooks in WordPress plugins with Atom editor

I mentioned in my post, “Safely adding code to WordPress” that you can add code to WordPress plugins, themes and even the core, without altering core functionality. That’s done using action and filter hooks, as explained in that post.

Sometimes it’s not easy to find those hooks. So here’s a guide on how to find them quickly using the free and cross-platform Atom editor.

THE details

To search for hooks in a plugin, download the plugin .zip file that you’d like to search through. I mentioned MarketPress in the walkthrough video, you can use any plugin though.

MarketPress download

Extract the plugin’s .zip file on your hard drive, then go into the extracted folder and open one of the files in Atom.

Then press Ctrl Shift F to open the Find/Replace panel.

Atom find/replace

Enter “do_action” if you’d like to find action hooks, or “apply_filters” if you’d like to find filter hooks. Then press ENTER to commence the search. You’ll see a new panel full of search results.

Atom search results

Simply click any of the items in the search results panel and Atom will open the file and take you to the respective line of code.

Simplifying the search

The Minimap package (I often call them plugins) for Atom makes searches much easier. Just install it through the built-in installer in Atom. Press CTRL , to open the settings panel, then click on Install. Type ‘minimap‘ in the search bar and click the Install button for the respective packages.

Install minimap package in Atom

By installing all the minimap packages, you should be able to select a portion of code and see all occurrences of that selected code highlighted in the minimap.Atom Minimap Highlight

Please feel free to ask if you have any questions about all this.


Finding hooks in WordPress plugins with Atom editor

Adding code to WordPress without messing things up

Altering the way WordPress works rarely requires changing any of the core WordPress code. The same often holds true for altering plugins and themes. That’s due to action and filter hooks, they provide a way to add your own code without changing the original code, meaning your added code will generally be safe when updates of the original code are made.

Most WordPress developers will provide various hooks in their plugin or theme code so that other developers can extend their built-in features, or so they can extend them later themselves.

Creating hooks

The following are the two functions WordPress provides for developers to add hooks:

  • do_action – plugins will use this to create actions for others to tie into.
  • apply_filters – plugins will use this to create filters for others to manipulate data or content used by the plugins.

The difference between the two (actions and filters) is that any arbitrary code can be executed with action hooks, whereas filters let developers alter specific data or content.

Using existing hooks

The following two functions allow developers to tie into the action and filter hooks defined by the functions above:

  • add_action – using this, you can tie into actions created with do_action.
  • add_filter – using this, alter content made available through apply_filters.

More about hooks at the WordPress codex: Hooks, Actions and Filters

A simple, core example

A simple example would be to use the_content filter hook built into WordPress to easily replace certain content. In the following case, I’ve searched for just the first occurrence of the word ‘WordPress’ within all post content and added a link to

In the WordPress core, in the file wp-includes/post-template.php, you’ll see a line like so:

$content = apply_filters( 'the_content', $content);

We tie into that defined filter using the add_filter function in the example, and simply reference a new function containing the code we’d like to run. Then, every time WordPress makes use of the_content hook, our code will be run!

You can browse and search through all the core hooks here:

Plugin example

As a quick plugin example, MarketPress e-commerce plugin can be extended to give a price discount based on criteria such as the user’s role on the site. You’ll see a method to achieve that as follows:

You’ll see it uses a filter hook called ‘mp_product_price‘. That’s defined in the plugin file marketpress.php like so:

$price = apply_filters( 'mp_product_price', $price, $product_id );

MarketPress was designed to allow code-based price changes and provides two values for that operation, $price and $product_id. we’ve just tapped into that and returned an adjusted $price variable.

Adding code to WordPress

The best way to add code to WordPress is usually by creating a plugin, or by adding it to your theme’s functions.php file. This would generally involve creating the code in a text editor (I’d recommend Atom), then uploading that to your site via FTP.

It’s also possible to add code through plugins such as Code Snippets. I’ve often used it in the past myself, for quick testing purposes. There’s just an added layer of concern because if your code is problematic, it could cause your site to be inaccessible, so doing it by FTP would provide a way to quickly revert back.

I hope that’s all intuitive, please feel free to ask any questions. 🙂

Adding code to WordPress without messing things up