Add Optional Page Settings in WordPress Using Advanced Custom Fields Plugin

By December 18, 2015March 20th, 2017Blog, Wordpress
WordPress Tutorials by Allure Web Solutions

In this post I will talk about using the Advanced Custom Fields (ACF) plugin to make certain parts of a WordPress page option in your custom theme. It’s actually quite easy. In my example, I will show how to make the page title an optional item. You can follow the same pattern for any other parts of a page that you want to make optional.

Step 1: Install ACF Plugin

Step 2: Create Page Options Field Group

  1. Go to Custom Fields > Add New
  2. Name your field group Page Options (or whatever you want)
  3. Add Field
    1. Label: Hide Title
    2. Type Checkbox
  4. Location: Show this field group if Post Type = Page (or whatever you want)

Page Options ACF

Step 3: Customize your theme

  1. Let’s assume you only want to make the title optional on the page template
  2. Open the page.php template file
  3. Find the location of the title
  4. Put in the code below to optionally show the title
    1. hide_title corresponds to the Name of the Hide Title field in ACF
    2. The logic of the code: If the hide_title checkbox isn’t checked, display the code below, otherwise (if checked), don’t display the code below
<?php if ( !get_field('hide_title') ) : ?>
    <h1 class="page-title" itemprop="headline"><?php the_title(); ?></h1>
<?php endif; ?>
Mike Doubintchik

Author Mike Doubintchik

More posts by Mike Doubintchik

Leave a Reply