Auto-add paragraphs to custom field?

Why don’t you use apply_filters( ‘the_content’, $var ); when outputting your custom field? You don’t really want to save the extra paragraphs, otherwise you’ll end up seeing them when editing the custom field. This is not what happens with WordPress. If you’re not happy with what the_content does (it does a lot of things including … Read more

Display custom field only if value present?

The easiest way would be to add a simple conditional: $values = get_post_custom_values(“listing_heading_10″); if ( $values ) { ?> <h3 class=”listing-title”><?php echo $values[0]; ?></h3> <?php } That said, is there any reason that you can’t put your output code in a foreach loop? e.g. $values = get_post_custom_values( ‘some_value’ ); foreach ( $values as $value ) … Read more

custom field to always to .get_the_title()?

<?php function add_subtitle($title, $id) { $subtitle = get_post_meta($id, ‘myCustomField’, true); $new_title = $title; if(!empty($subtitle)) $new_title = $subtitle . ‘: ‘ . $new_title; return $new_title; } add_filter(‘the_title’, ‘add_subtitle’, 10, 2); Basically, this uses the the_title filter to add the subtitle to your title. It only adds it if that custom field is available, otherwise, it leaves … Read more

Adding a custom field or metabox to the post-thumbnail widget?

Just filter admin_post_thumbnail_html and append your checkbox HTML: add_filter( ‘admin_post_thumbnail_html’, ‘wpse_71501_thumbnail_options’ ); function wpse_71501_thumbnail_options( $html ) { return $html . <<<html <p> <label for=”big_thumbnail”> <input id=”big_thumbnail” name=”big_thumbnail” type=”checkbox” /> Use big thumbnail </label> </p> html; }

How can I combine meta_query queries?

Using your constructed array, I think this is the correct syntax: $meta_query_args = array( ‘meta_key’ => ‘price’, ‘meta_value_num’ => 1000, ‘meta_compare’ => ‘<=’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘roomcount’, ‘value’ => 3, ‘type’ => ‘numeric’, ‘compare’ => ‘>=’ ), array( ‘key’ => ‘bathroomcount’, ‘value’ => 2, ‘type’ => ‘numeric’, ‘compare’ => … Read more

Currency (price) formating on custom fields

if you want to process the field after submitting, php’s number_format function is what you need: $price = number_format( $number, 2, ‘.’, ‘,’ ); but if you want to change how the number is displayed as it’s typed in, try jQuery autoNumeric