Any way to make custom taxonomy field searchable?

Here’s the code. You can change $post_type and $custom_fields according to your needs. function extend_admin_search( $query ) { // Extend search for document post type $post_type=”document”; // Custom fields to search for $custom_fields = array( “_file_name”, ); if( ! is_admin() ) return; if ( $query->query[‘post_type’] != $post_type ) return; $search_term = $query->query_vars[‘s’]; // Set to … Read more

I want to display the content of a text field only if it has been entered

Do echo inside an if statement. function show_my_message() { $settings = get_option(‘wc_checkout_message_settings’); //Check if the array is set if( isset($settings[‘wc_checkout_message_text_field_0’]) && !empty($settings[‘wc_checkout_message_text_field_0’]) ){ echo $settings[‘wc_checkout_message_text_field_0’]; } //Check the other value and show it if(isset($settings[‘wc_checkout_message_text_field_1’]) && !empty($settings[‘wc_checkout_message_text_field_1’]) ){ echo $settings[‘wc_checkout_message_text_field_1’]; } }

Use custom field value as href

To retrieve a value after using add_settings_field() you should use get_option(). So you could do something like this… $value = esc_html(get_option(‘option_name’)); if ($value) { echo ‘<a href=”‘ . $value . ‘”>Click Here</a>’; } You just need to change option_name to your field name. The code will grab the value and if it isn’t false echo … Read more

Custom Search, MySql Query Gone Wrong?

This doesn’t seem especially complex, but does seem bulky and prone to errors. As I answered couple of times on similar issues – if this isn’t time critical then wait for WP 3.1 because it will have major improvements for querying by custom fields. See Advanced Metadata Queries for brief writeup on upcoming improvements. For … Read more