ThunderVike Posted July 21, 2010 Share Posted July 21, 2010 I have wordpress 3.0 installed on PHP 5. I am using a custom theme that creates individual classifed ads whose fields, including custom fields, are stored in the postmeta table. Each Post/Ad may have different custom fields associated with it because some of the ads, depending on category or sub-category, may have different custom fields stored with that post/ad. There is an existing custom field function in the functions.php that pulls all the custom fields associated with that $post_id value of the ad or post called for. I created a similar function that JUST pulls the custom fields that store CHECKBOX values. I created this so that I can separate the checkbox values stored in arrays in the "meta_value' fields identified by a "meta_key" named 'cp_checkbox_'variable name here'. I want to modify this part of the function...with a filter foreach ($results as $result) : // now grab all ad fields and print out the field label and value $post_meta_val = get_post_meta($postid, $result->field_name, true); if (!empty($post_meta_val)) if($result->field_name != 'cp_price') echo '<li><span>' . $result->field_label . ':</span> ' . cp_make_clickable($post_meta_val) .'</li>'; // make_clickable is a WP function that auto hyperlinks urls endforeach; } else { echo __('No ad details found.', 'cp'); } I want to EXCLUDE rows whose "meta_key" value includes the word 'checkbox' When I created another function to FOCUS on extracting just those rows whose meta_key field contained the word 'checkbox' I made this one of the sql query conditions: `wp_postmeta` . `meta_key` LIKE '%%checkbox%%' this works well and selects rows whose meta_key may vary in naming...such as "" or" cp_checkboxstuff" etc....it catches the variant names as long as they have some form of ''checkbox" So, if I want one function to grab just the rows containing checkbox meta_value and another function to grab just the custom fields that are NOT checkboxes What is a Wordpress filter that I can apply to $post_meta_val = get_post_meta($postid, $result->field_name, true); that will strip out any custom field rows where the "meta_key" contains some variant of "...checkbox..." I am trying to do this with the global values already present instead of building another sql query directly to the database. I see all kinds of way to strip out POSTS according to tags and categories but nothing yet specifically for creating this filter on custom fields called. Thanks for your help, Wordpress geeks! Quote Link to comment https://forums.phpfreaks.com/topic/208442-calling-wordpress-experts-filter-custom-fields/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.