Home / custom field / Custom field outside loop
  • Pingback: Tweets that mention Wordpress Custom field outside loop – wpsnipp.com Wordpress code snippets for your blog -- Topsy.com()

  • Other than your shortcode trickery (very nice), how do you get the custom field INSIDE the loop? Is that a default WP thing?

    • echo get_post_meta($post->ID, ‘CUSTOM-FIELD-NAME’, true);

  • I think I’m still not understanding what you are trying to do can you explain in a little more detail.

  • jaffa

    Can you please tell me how I can add a label before the custom field value? And, this label should only be visible when a custom field is present.

    I can’t figure it out myself.


    • global $wp_query;
      $postID = $wp_query->post->ID;
      $cf_meta = get_post_meta($postID, ‘CUSTOM-FIELD-NAME’, true);
      if($cf_meta != ”){
       echo ‘label text: ‘.$cf_meta;

      • jaffa

        Thank you. That was perfect!

  • Samuel

    This is great, thanks for sharing. One addition, how can I add the ability to use shortcodes in my custom meta box outside the loop?