Build Your Own Business Website header image

Lesson 7 – Creating Custom Child Theme Options

Difficulty Level -

Filed Under Topics -

Listed Under Lesson Subjects -

Applies to -

In this Customizing the Genesis Theme lesson we demonstrate how to create custom child theme options that allow the user to customize the output of the page. In this case, we are specifically customizing the Front Page. Here you’ll learn all about setting up custom child theme settings.

The Big Idea – Use Child Theme Options to Control the Display of the Front Page

  • Create theme settings that will control which posts display in each of 3 columns
  • They can choose
    • taxonomy
    • term
    • number of posts to show

Add the Magazine Style Loops to the Front Page

  • Grab the code from lesson 6
  • Setup 3 sets of query args
    • category
    • posts to show
  • Setup 3 columns
  • Drop a query into each column
  • Hook it

Anatomy of Genesis Child Theme Options

  • Setup Defaults
  • Choose the sanitization filters
  • Add the meta box
  • Create the meta box form

Create the Genesis Child Theme Options Defaults

  • filter – genesis_theme_settings_defaults
  • passes default settings
  • need to return defaults with new
  • Create the function

Choose Genesis Options Sanitization Filters

  • action hook – genesis_settings_sanitizer_init
  • genesis function – genesis_add_option_filter
    • name of the filter
    • Genesis settings field constant
    • array of setting that need this applied to them
  • Filters available
    • one_zero,
    • no_html,
    • safe_html,
    • requires_unfiltered_html

Create the Theme Options Metabox

  • action – genesis_theme_settings_metaboxes
  • passes a hook location variable – $_genesis_theme_settings_pagehook
  • add_meta_box
    • id of meta box
    • Title of meta box
    • name of function that will populate meta box
    • admin page location – pass the hook here
    • context
    • priority

Create the Theme Options Form

  • User Selected Options

Configure the Front Page Template to Use the New Theme Options

  • Put Options into Values and Add Choice of tag_id or cat.
    • Casting the variable

Use a Select Box in the Theme Options Form

  • Add Term List to Make the Form User Friendly
    • Replace Text Input Types with Select Input Types
    • Set a Value and Selected Statement

Dynamically Populate the Theme Options Select Box

  • Create the First Option
  • Create the Second Options

Create the Form for Multiple Theme Options

  • Add a Description to the Form
  • Add Labels to the Columns
  • Complete Options Settings
  • Complete Labels

Question and Answer

Save $200 on Membership Now!

Start learning today for as little as
$0.82 PER DAY!
Subscription Options
0 Comments… add one
0 comments… add one