Is there any non-plugin solution to add template meta box on the category edit screen? Template meta box like that on the page edit screen, but this one for category. I'd like to have this function built into the theme page. Something similar to the one Mike Schnikel did for Scott B here.
3 Answers
I'm currently working on a theme framework and one of it's classes is a custom category template class which does just what you are asking for: it adds a select field to the category edit screen that lets you select a template, just like with pages, and i just published it as a plugin
and if you are not up with using a plugin then simply take a look at the plugins code which is a single class that you can even use from your functions.php file.
-
include category_template.php file in function.php, it came back with "Fatal error: Class 'Custom_Category_Template' not found in category_template.php on line 138". Can you please help?– Sean LeeCommented May 6, 2012 at 9:17
-
@SeanLee It had a little bug which was fixed in the updated version 0.2, so make sure you have the latest. Commented May 6, 2012 at 9:52
-
I just downloaded from the link above, it's 0.2 from wordpress.org. That's the one giving me error.– Sean LeeCommented May 6, 2012 at 9:57
-
@SeanLee the error
Fatal error: Class 'Custom_Category_Template' not found in category_template.php
was fixed in version 0.2 which was pushed to the WordPress plugin repository about 6 minutes ago, so if you are still getting that same error it's not the latest version. if you are getting a different error the let me know. Commented May 6, 2012 at 10:05
Please have a read this:
add-meta-box-to-category-edit-screen
anything-like-add-meta-box-for-categories
Hope can help you!
-
Unfortunately adding a template meta box is different from just adding a meta box, cause it needs to have a hook into WP to apply the template. Thanks anyway.– Sean LeeCommented May 2, 2012 at 14:39
Here is an example of adding Meta to Categories, you can style and choose the input type