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
|
1 |
<?php add_action('admin_menu', 'shortcode_gen_to_post_types');?> |
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"]
__(
that Kaptinlin provides. If you must know this code is used for the translation process.
[/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.
|
1 2 3 4 5 6 7 8 9 10 |
function shortcode_gen_to_post_types () {
add_meta_box(
'shortcode',
__('Shortcode Generator','striking_admin'),
'theme_shortcode_generator_iframe',
'actooltip',
'normal',
'high'
);
} |
That is basically it. Don’t worry about the first three paramaters:
- ‘shortcode‘,
- _(‘Shortcode Generator’, ‘striking_admin’),
- ‘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.





