WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to suppress the output of one of my custom fields. Is there a way to do this using the <?php the_meta(); ?>command?

share|improve this question
This works beautifully! THANK YOU so much for your help - I'm certain others will benefit as I've seen similiar requests for help~ I am unable to select this as my answer but will do so as soon as I've figured out what the problem is. – mktggirl Oct 18 '11 at 20:46
We're glad to have been of help! – soulseekah Oct 19 '11 at 3:03
up vote 2 down vote accepted

The function, the_meta() allows you to hook to the the_meta_key filter (which currently is not documented in the Codex); this is where it fires off:

// wp-includes/post-templates.php @line 744
echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value);


This filter is applied to each and every meta pair, which means that you can add a filter to suppress based on a specific key, value or key/value pair like so:

function wpse31274_exclude_my_meta( $html, $meta_key, $meta_value ) {
    if( 'remove_this_key' != $meta_key )
        return $html;
    return '';
add_filter( 'the_meta_key', 'wpse31274_exclude_my_meta', NULL, 3 );

Tried and tested, seems to work, so I hope it helps.

share|improve this answer
Thanks for the edit, t31os, looks real good now. – soulseekah Oct 17 '11 at 11:26

Have you tried with delete_post_meta($post_id, $key, $value);?

Since the_meta has not any parameter maybe delete_post_meta is your best option, however I'm totally guessing, I would need to know the context of your project in order to give you a better answer :)!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.