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

Deleting a custom field field

If you have access to phpMyAdmin, these steps should do the trick: Step 1: Login to your hosting account and launch myPHPadmin from the cPanel, or equivalent, to access the WordPress database engine. Step 2: Enter a select SQL command to list all the meta keys you want to remove. In this example, I want … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)