Display custom field value as a hyperlink

<?php $custom_fields = get_post_custom($post_id); //Current post id $my_custom_field = $custom_fields[‘website’]; //key name foreach ( $my_custom_field as $key => $value ) echo $key . ” => <a href=”” . $value . “”>Click Here</a><br />”; ?>

querying a custom field

i am not sure that this is place you should change the shortcode This code retrieves several values and not one.. as i understand it you are looking to get one value back right ? that’s much simpler and doesen’t require the use of “foreach” you simply put this in the desired location <?php echo … Read more

Query_posts with custom field meta value

The best solution i found for querying posts where the meta_key IS NOT or doesn’t exists is to use the posts_where filter with a small sub-query, try this: //paste this function in your theme’s functions.php function metakey_no_featured( $where ) { global $wp_query; global $wpdb; $where .= $wpdb->prepare(” AND $wpdb->posts.ID NOT IN ( SELECT post_id FROM … Read more

How can I do a variable for meta_query?

Use a ternary operation to keep it trim. array( ‘key’ => ‘rob_value’, ‘value’ => $rob, ‘compare’ => ( empty( $rob ) ? ‘!=’ : ‘=’ ) ); Breakdown, incase you’ve not seen ternary operators before.. array( ‘key’ => ‘rob_value’, ‘value’ => $rob, ‘compare’ => ( // If empty( $rob ) // Then ? ‘!=’ // … Read more