Enabling the Headway Meta boxes in your Custom Post Types

You will need to know how to create custom post types to understand this tutorial.  This tutorial does not cover creating your own Custom Post Types.

You’ll notice that when creating/editing Posts and Pages in WordPress, there are some Headway specific metaboxes:

  • Title Control
  • Shared Layout
  • Featured Image Position
  • SEO (if using Headway’s SEO options)
  • Custom CSS Class(es)

These meta boxes do not show up when creating/editing Custom Post Types (CPT) unless you add support for it.  So the question is.. how?  The method depends on whether you want to add support for all Custom Post Types or just certain ones and whether you want to enable all meta boxes, or just some.

First things first

The things you need to know are:

headway-admin-meta-box-template corresponds to the Shared Layout meta box
ctp_mb_sl

headway-admin-meta-box-alternate-title corresponds to the Title Control meta box
ctp_mb_tc

headway-admin-meta-box-post-thumbnail corresponds to the Featured Image meta box

ctp_mb_fip

headway-admin-meta-box-display corresponds to the Custom CSS Class(es) meta box

ctp_mb_cc

headway-seo corresponds to the Headway SEO meta box

ctp_mb_seo

Manually created CPT

Either with a child theme or custom site plugin (not a pre-built plugin)

You can create CPT by adding the code to your child theme functions.php or you can also create your own custom site plugin and place the code to create your custom post type. Whatever method you choose, you need to add additional items to the supports array.

A supports array for your CPT might look like this

'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments')

If you wanted to add support for Headway’s Title Control meta box to your CPT, you would need to add headway-admin-meta-box-alternate-title to the supports array.

For example:

'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'headway-admin-meta-box-alternate-title')

Pre-built Plugin created CPT

A plugin you downloaded from repository or purchased, not one you created yourself

If you are using a pre-built plugin to create your CPT (examples include Types, CPT UI, More Types, etc), unless the plugin has an option to declare support for the Headway meta boxes (for example, although an older plugin, More Types allows this), you will need a child theme or a custom site plugin to add support for the Headway meta boxes.

You can’t just edit the plugin to add the support because upon upgrade of the plugin, you will lose your changes.

So, for example, if you wanted to declare support for Headway’s Shared Layout meta box, here’s the code you would use

add_action('init', 'my_custom_init');
function my_custom_init() {
    add_post_type_support( 'product', 'headway-admin-meta-box-template' );
}

Where product is the slug of your CPT (this is the slug created by WooCommerce). To add support for more meta boxes, you could add to it. To declare support for the Shared Layout and Title Control metaboxes:

add_action('init', 'my_custom_init');
function my_custom_init() {
    add_post_type_support( 'product', 'headway-admin-meta-box-template' );
    add_post_type_support( 'product', 'headway-admin-meta-box-alternate-title' );
}

Noting that you would have to repeat this for each CPT/meta box combination. If, instead, you wanted to have every CPT that you have support the Headway meta boxes:

function hw_cpt_metabox_support() {
        $post_types = get_post_types();
	foreach ( $post_types as $post_type ) {
    	add_post_type_support( $post_type, 'headway-admin-meta-box-template' );
    	add_post_type_support( $post_type, 'headway-admin-meta-box-alternate-title' );
    	add_post_type_support( $post_type, 'headway-admin-meta-box-post-thumbnail' );
        add_post_type_support( $post_type, 'headway-seo');
        add_post_type_support( $post_type, 'headway-admin-meta-box-display' );
	}
}
add_action('admin_init', 'hw_cpt_metabox_support');

This code loops though all CPT and adds support for all Headway meta boxes to all post types.

If you wanted to only add certain meta boxes to all post types, then you can remove the ones corresponding to the appropriate meta box.

Any questions? Ask in the comments are start a thread in the forum!

Screencast Thursday: Working with Shared Layouts

As indicated in the video, the first few minutes are me going over the when/why to use Shared Layouts. If you want to read that (below) instead, skip to 4:00 in the video.

Summary of when/why to use shared layouts:

  • Use Shared layouts when layout inheritance isn’t enough. Example: You want some posts to have one layout and others to have a different layout
  • When you want to export a Template to use on a different WordPress installation either yourself or another Headway user
  • Or just because. I personally prefer using Shared Layouts over cloning. There is actually less data stored in the database and such this way.

Summary of things to know:

  • You can’t (yet) assign Shared layouts (or any layouts) to all posts in a specific category
  • You can’t (yet) mass-assign Shared layouts to posts/pages

Creating a functional header

This comes from a request in the forum on a walkthrough of how to have a header with logo, contact details and social media links. First thing to understand is that you can have multiple wrappers, which are containers for your blocks. This allows you to style groups of blocks differently. Let’s start in the…Continue Reading

How to use FancyBox Lightbox with Headway

Skills you will need: uploading files to your server, creating a Headway child theme, creating a WordPress gallery. In this tutorial, I will show you how to use FancyBox with Headway.  You certainly can use a plugin to take of this functionality for you but this tutorial is plugin free. Please note the licensing for…Continue Reading

Screencast Thursday: Using Custom Fonts

As promised in the video, here’s the code I used in the Live CSS Editor @font-face { font-family: ‘aleoregular'; src: url(‘wp-content/themes/code-child/fonts/Aleo-Regular-webfont.eot’); src: url(‘wp-content/themes/code-child/fonts/Aleo-Regular-webfont.eot?#iefix’) format(‘embedded-opentype’), url(‘wp-content/themes/code-child/fonts/Aleo-Regular-webfont.woff’) format(‘woff’), url(‘wp-content/themes/code-child/fonts/Aleo-Regular-webfont.ttf’) format(‘truetype’), url(‘wp-content/themes/code-child/fonts/Aleo-Regular-webfont.svg#aleoregular’) format(‘svg’); font-weight: normal; font-style: normal; } @font-face { font-family: ‘aleolight'; src: url(‘wp-content/themes/code-child/fonts/Aleo-Light-webfont.eot’); src: url(‘wp-content/themes/code-child/fonts/Aleo-Light-webfont.eot?#iefix’) format(‘embedded-opentype’), url(‘wp-content/themes/code-child/fonts/Aleo-Light-webfont.woff’) format(‘woff’), url(‘wp-content/themes/code-child/fonts/Aleo-Light-webfont.ttf’) format(‘truetype’), url(‘wp-content/themes/code-child/fonts/Aleo-Light-webfont.svg#aleolight’) format(‘svg’); font-weight: normal; font-style: normal; }…Continue Reading

How to use Gravity Forms with Headway

We’re big fans of Gravity Forms here at Headway so we thought we’d go over how to use Gravity Forms with Headway. Using WordPress Simply create your form as you normally would in the Gravity Form setup, then use the “Add Form” TinyMCE button to select your form. For my screenshots, I’ve created a page…Continue Reading

Headway Newsletter

Get the latest updates from our blog directly in your inbox! Are you ready to learn the latest from Headway Themes?

Copyright © 2014 Vesped Inc. All Rights Reserved. Proudly Powered by Headway and WordPress