Quantcast
Channel: Custom Post Meta – Build Your Own Business Website
Viewing all articles
Browse latest Browse all 10

Lesson 17 – Using Custom Post Meta in Thesis

$
0
0

In this Thesis theme video tutorial lesson of our Customize Thesis Like a Pro course you will learn how to use Custom Post Meta in Thesis. We begin with an introduction to what it is and the typical WordPress way of creating custom meta boxes.

We focus on the WPAlchemy Class for creating the meta boxes and show how to do the initial setup of the class and how to use it. This introduction is followed by two examples using custom post meta to add custom page specific content to the sidebar and adding sidebar configuration options.

The lesson is not availableWhat is Custom Post Meta? – Watch the Video

  • Description

    • What is meta data?
    • Other types of meta data – User, Taxonomy
  • Examples

    • Thesis theme SEO
    • Thesis theme post image
  • Interface for saving it

    • Custom fields
    • Custom meta boxes
  • How post meta data is stored

    • Stored in post_meta table
    • 4 parts
    • meta id
    • post id
    • meta key
    • meta value

The lesson is not availableThe Typical WordPress Way of Creating Custom Meta Boxes – Watch the Video

  • All of the meta box functions are manually coded

    • Setup the post meta box
    • Create the form for collecting the post meta
    • Secure the form to prevent unauthorized updates
    • Collect the form data
    • Make sure the data is from a trusted source
    • Compare the new data to existing data
    • Update existing data with new data
  • Compared to the WordPress Settings API

    • Define the settings fields
    • Create the form
    • Sanitize the data
  • This has spawned a number of solutions

    • Genesis meta box API
    •  Thesis hints
    • WPAlchemy
    • Various plugins

The lesson is not availableInitial Setup of the WPAlchemy Class – Watch the Video

  • What is WPAlchemy?

    • API for creating meta boxes
    • website – http://www.farinspace.com/wpalchemy-metabox/
  • Download WPAlchemy

    • https://github.com/farinspace/wpalchemy
    • Select the “Master” branch
    • Download the zip file
  • Setup WPAlchemy file structure for Thesis

    • Extract the file
    • Move wpalchemy to custom
    • Move metaboxes to custom
    • Create an “examples” folder – move files (except meta.css)
    • Delete setup.php
  • Tour of the files

    • class files
    • example files
      • spec files
      • meta files
  • Setup the “includes”

    • include the class
    • enqueue the admin style

The lesson is not availableUsing the WPAlchemy Class – Watch the Video

  • 3 part process

    • define the meta box
    • define the meta box form
    • get the post meta
  • Define the meta box

    • Extend the class
    • Define the options
      • id
      • title
      • types
      • include_template
      • context
      • priority
      • template
      • mode
      • prefix
  • Define the meta box form

    • This is an HTML form
    • Wrapping div
    •  Define/set the field – using the post meta name
    •  Access the name
    •  Access the value

The lesson is not availableExample #1 – Add Custom Page Specific Content to the Sidebar – Watch the Video

  • Define the meta box

    • Give it a unique name
    • id
    • title
    • context
    • priority
    • mode
    • template
  • Define the meta box form

    • copy the “simple” file & rename
    • edit descriptive text
    • change the field names
    • input type=text
    • text area
  • Test

  • Create the function to use the meta

    • unique function name
    • access the global post variable
    • get_post_meta()
    • setup variables
    • if the variables have values
    • write the html
    • hook the function
    • test

The lesson is not availableExample #2 – Add Sidebar Configuration Options – Watch the Video

  • Define the meta box

    • Give it a unique name
    • id
    • title
    • types
    • context
    • priority
    • mode
    • template
  • Define the meta box form

    • copy the first file
    • copy the checkbox from the checkbox file
    • input type=checkbox
    • create field names
    • checkbox value
  • Create the function

  • Add the function to our control structure


Viewing all articles
Browse latest Browse all 10

Trending Articles