Request: Custom fields for categories
-
It would make semi-intelligent displays so much easier, more flexible and less prone to breakage. Right now, there’s only the slug, title and description to check against – all of which could be subject to change.
-
Example of visual editor use:
I use the original plugin on one site. The site owner is very non-technical. One of the custom fields is being used for multi-paragraph blurbs about a category, longer than the category descrip field allows. Its handy for her to have a visual editor because she doesn’t want to deal with<p> <br /> <a>
and all of that to mark up her thoughts. She just wants to wrote them down as they come to her. Her mind just does not work in HTML.I respect your thoughts about the editor, just explaining its value in certain cases.
@stvwlf, thanks!
How to upgrade plugin category-fields for wp 2.8
changes in category_fields.php:
/////////////////////////////
[1]
wp_enqueue_script(‘wp_tiny_mce’);
replace with:
add_filter(‘admin_head’,’ShowTinyMCE’);
function ShowTinyMCE() {
// conditions here
wp_enqueue_script( ‘common’ );
wp_enqueue_script( ‘jquery-color’ );
wp_print_scripts(‘editor’);
if (function_exists(‘add_thickbox’)) add_thickbox();
wp_print_scripts(‘media-upload’);
if (function_exists(‘wp_tiny_mce’)) wp_tiny_mce();
wp_admin_css();
wp_enqueue_script(‘utils’);
do_action(“admin_print_styles-post-php”);
do_action(‘admin_print_styles’);
};[2]
global $wpdb, $table_prefix;
$wpdb->query(“CREATE TABLE IF NOT EXISTS ‘$wpdb->cat_fields’ (
‘field_id’ INT NOT NULL auto_increment ,
‘cat_id’ INT NOT NULL,
‘kkeys’ TEXT NOT NULL ,
‘kval’ TEXT NOT NULL,
PRIMARY KEY ( ‘field_id’ ))”);replace with:
$sql = “CREATE TABLE ” . $cat_fields . ” (
‘field_id’ INT NOT NULL auto_increment ,
‘cat_id’ INT NOT NULL,
‘kkeys’ TEXT NOT NULL ,
‘kval’ TEXT NOT NULL,
PRIMARY KEY ( ‘field_id’ )
);”;
require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);
dbDelta($sql);/////////////////////////////
It’s work for me.
Do you intend to release soon a version of the improved plugin?
Thanks
Sonika! You’re a star!
Wondered why the image editor didn’t work. I’m running 2.8.4. You’re a godess for the fix. Thanks again!
A damn useful plugin, with Sonika’s mod above. Hope someone much cleverer than me develops this, along with Sonika’s mod for 2.8+ use.
I do have a question about using the plugin:
Can I present my category fields on a single page of that same category? I tried using a single cat template but no luck.
To echo maorb, is there a current release of this plugin? I love the get_custom plugin from coffeetocode (it’s my #1 fav) but am always looking for plugins that make using WordPress as a CMS better….
put me on your list for being willing to beta test it. please!
syncbox AT gmail DOT com
I tested category-fields mentioned above without much success in 2.8.4.
Perhaps I’m missing something, but what’s wrong with Eric Le Bail’s Category Meta Plugin. It’s rather barebones, but is exactly what I needed for assigning additional attributes to categories.
I will say while Category Meta works great as is, but I’m really inspired to to extend it with functionality found in the popular more-fields plugin.
I tried https://coffee2code.com/wp-plugins/custom-fields-for-anything/ and it doesent work.
-after installed, u cant edit/add/manage anythingI tried https://mtncomp.com/upload/category-fields.zip, it also dident work (with Sonika’s update)
-after installed, get a error messege in wordpressI tried https://www.ads-software.com/extend/plugins/wp-category-meta/ and it dident work
-added custom field, pasted code in php files, the tags dident showIs there one that works?
I tried all of the aforementioned plugins with 2.9.1 and no dice. Was able to add the fields in the admin area, but couldn’t get it to echo on the category page based on the php calls form wp-category-meta readme file.
This has been bugging me too, and I’ve now figured out a way to do it very simply using the HeadSpace2 plugin (which many of you might already have!)
Simple tutorial here: Custom Fields for Categories
I’d love a tweet or link if you found it useful.
jeanfayette,
Headspace isn’t working for me, nice to have a custom field in the category editor but alas the template code just isn’t calling the custom value. I followed the instructions!Can you paste your code?
Is the custom value coming up as a field on your category description page?
I am having the same problem.
Installed HeadSpace2, added a custom field called “first-name”
In the themes, I am calling it with the following code:
<?php echo MetaData::get_custom (‘first-name’); ?>Nothing was showing up. Then I realized the same field – “first-name” is also on every individual post. When I enter something in the “first-name” field on the individual post, it returns the value.
But, how do I access it for specific categories?
Thank You!
You must be calling it on single.php or in the single loop – so it’s looking for the custom value for the individual post.
If you insert your value on the category page and call the custom field on an archive or category page outside of the posts loop, it will work fine.
ok, so it will only work on the archive/category page, outside the loop?
i am trying to use the categories as the author name. i have the last name in the main category field, and the first name in the custom field.
but i need to bring up both values in the index.php page for every single post.
is there no way of doing that?does anyone have another solution? the reason why i have to separate the last name and first name is because i need it to appear as:
smith, joe
and
joe smiththanks!
- The topic ‘Request: Custom fields for categories’ is closed to new replies.