Striking Theme - Add a Meta Box to Custom Post

Contact: burt (AT) islandcolors (DOT) com | 415.704.1832

striking-premium-theme

Striking Theme – Add a Meta Box to Custom Post

Add Striking ‘s Meta Box to A Custom Post

It is no secret that one of my favorite premium themes is the Striking Professional Theme found at Theme Forest.  As of May 2nd 2011, Striking has been downloaded  over 3,300 times, making it the second most popular WordPress theme at Theme Forest.

Not only does Striking have many great features and can almost be considered a framework – one of the few things lacking is his own hooks and filters –  

Striking has over 100 shortcodes, 12 widgets and unlimited color combinations and is one of the few themes that is priced at $40

and is surprisingly flexible especially with the creative use of both the blog and portfolio shortcodes that can be inserted on both pages and posts. The author who calls himself Kaptinlin is an extremely  talented WordPress Programer, which is evident from  his code and the flexibility that is built into the theme.

Striking Theme Shortcode Generator

All of the 100+ shortcodes can be inserted into the WordPress Editor through selection list – many themes don’t use drop-down list or meta boxes to insert shortcodes. Kaptinlin chose to use a metabox to generate the shortcodes instead of adding  it to the top bar of the WordPress editor.

A Problem With Custom Post Types

Putting the Shortcode Generator in a metabox instead of  an icon on the editor makes it difficult to use the Shortcode Generator with Custom Post Types that either you create or are created when you install  plugins.

To be sure, Kaptinlin, provided an area in the Striking Options -> Advanced where you can select what Custom Post Types

the  Shortcode Generator Meta box will be available, but again this does not extend to Custom Post Types that did not come with the Striking Theme.

Two Additions to the Function.php File

It is relatively simple to add the Shortcode Generator Metabox to an individual Custom Post. With the following method you don’t have to hack any of the Striking Theme core files. All you need is access to the theme’s function.php file or you can use your own custom one if you follow the strategies of  Chris Pearson’s Custom Functions and Custom CSS strategy .

Open up your function.php file in your favorite editor and after the

Here is What add_action Does

This add_action is the WordPress hook that executes the function shortcode_gen_to_post_types when the admin menus area created. Make sure your function name matches the function that adds the meta box

Here is What the add_meta_box Does

The add_meta_box requires the following paramaters – getting the correct ones can be problematic but here is a simple way to find the registered custom post type – The list is as follows add_action(

[list type="blue"]

  • Line 3 is the ‘ID” of  the meta box registered name use ‘shortcode‘ for Striking
  • Line 4 is the title of the meta box use the strange looking php code
    __(

    that Kaptinlin provides. If you must know this code is used for the translation process.

  • Line 5 is the function that displays the meta box use ‘theme_shortcode_generator_iframe‘ in Striking’s case
  • Line 6 is the custom post type slug or registered name . I am using ‘actooltip‘ – You can find yours by using the Custom Post Slug Shortcode.
  • Line 7 is where you want the meta box to be placed ‘normal‘ for Striking
  • Line 8 is the priority of where the meta box should show – lets try ‘high
  • [/list]

    And Your Are Done

    And that is really all there is to it – for an in-depth look review the WordPress Function Codex on the subject.

    That is basically it.  Don’t worry about the first three paramaters:

    1. shortcode‘,
    2. _(‘Shortcode Generator’, ‘striking_admin’),
    3. theme_shortcode_generator_iframe

    these are correct and unless Kaptinlin changes them everything will work.

    If you would like to add the Shortcode Generator to ALL your Custom Post Types at once please read the tutorial and follow its simple copy and paste steps.

    Did You Know?

    Kaptinlin did Change the Shortcode Generator to display as an iframe when he upgrade from the 2.0 to the 3.0 version. If you did up-grade to the new version the above function would have broken.

    If you need help in finding the slug of your or a plugins custom post type, kindly review the following page Finding a Custom Post Type Slug follow the steps outline in the tutorial.

    Trackbacks for this post

    1. Striking Theme – Add a Meta Box to Multiple Custom Post | | Island Colors| Burt Gordon
    2. Get the Custom Post Type Slug |Burt Gordon

    Leave a Reply

    This is A Form

    Contact Me

    We would love to hear from you! Please fill out this form and we will get in touch with you shortly.