[Plugin: Category Custom Fields] quick function i wrote
-
I wrote two very basic functions to make it easier to retrieve data, thought i would share it if anyone wanted it. Might be duplicating the wheel here, not sure if the pre-made functions do this already. Only feature request I ask of the author is to be able to pre-define select menus with data, and use the wordpress image uploader api for image fields.
function get_cat_meta($id, $field_name) {
global $wpdb;
$query = “SELECTfield_valueFROMwp_ccf_ValueWHEREterm_id= ‘” . $id . “‘ ANDfield_name= ‘” . $field_name . “‘ “;
$result = $wpdb->get_row($query);
return $result->field_value;
}function get_all_meta($id) {
global $wpdb;
$query = “SELECT DISTINCTfield_nameFROMwp_ccf_Value“;
$result = $wpdb->get_results($query);
foreach ($result as $value) {
$slide[$value->field_name] = get_cat_meta($id, $value->field_name);
}
return $slide;}
The topic ‘[Plugin: Category Custom Fields] quick function i wrote’ is closed to new replies.