Quick Guide to WordPress Custom Fields

During a recent large project, I had a subcontractor who had a lot of experience with custom fields and from her I learned how to do them without a plugin. It’s actually quite easy, these are the steps you follow to add a custom field and display its contents in a WordPress template.

  • Create a custom template, upload it and apply it to a page in your site. If you upload and don’t see the template in the list in the editing page, try switching to the default theme and back, this usually will do the trick.
  • In your custom template page, you’ll need to do two things.
    • First, define the variable for the new custom field in a PHP statement.

    • Then add some PHP to display the contents of the custom field if it’s in use in the page.

  • Then in the WordPress page editor, under Custom Fields, click on Add New Custom Field and enter the name of the field in the left box, and the value in the right box
  • Update the page and take a look at it. You should now see your new custom field value in the page.

Dead simple, once I had to do it myself, and no need to add yet another plugin. You can create custom fields for any section of a page so that clients know where to enter what data.

3 comments

  1. I am actually attempting this right now for my testimonial section. I am having a problem with trying to figure out how to add positions. Thanks for your help.

Leave a Reply

Your email address will not be published. Required fields are marked *