Title: Empty custom fields.
Last modified: August 21, 2016

---

# Empty custom fields.

 *  Resolved [openboxstudios](https://wordpress.org/support/users/openboxstudios/)
 * (@openboxstudios)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/empty-custom-fields-2/)
 * Any thought on giving an ability to check if a custom field is empty? Or any 
   field for that matter. I keep trying to use this for some stuff and I want to
   because it’s nice and simple and something I can explain to my clients, however,
   I keep hitting these logic walls.
 * I’ve got it looping through to build a carousel of logos, but some have URLs 
   and some do not from a custom field.
 * Thoughts?
 * [https://wordpress.org/plugins/custom-content-shortcode/](https://wordpress.org/plugins/custom-content-shortcode/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/empty-custom-fields-2/#post-4884177)
 * Hello,
 * Thank you for mentioning this – I’ve needed this functionality of checking for
   empty custom fields before, so I added a new shortcode **[if flag]** for this
   purpose. Please see the latest update.
 * For example, this shows only products with serial numbers:
 *     ```
       [loop type="product"]
           [if flag="serial_number"]
               Product: [content field="title"]<br>
               Serial number: [flag]<br>
           [/if]
       [/loop]
       ```
   
 * The _flag_ parameter specifies the field to check, and **[flag]** displays the
   value of that field.
 * I hope that can provide a solution.
 *  Thread Starter [openboxstudios](https://wordpress.org/support/users/openboxstudios/)
 * (@openboxstudios)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/empty-custom-fields-2/#post-4884185)
 * Not sure if that’s working the exact way it should.
 * Take this example:
 *     ```
       [loop type="brand" taxonomy="brand-category" value="non-gmo" columns="3" orderby="menu_order"]
       [if flag="wpcf-brand-website"]
       <div class="team-member"><a href="[flag]" class="inline">[content field="image" size="thumbnail"]</a><h4 class="light"><a href="[flag]" class="accent-color">[content field="title"]</a></h4></div>
       [/if]
       [/loop]
       ```
   
 * It should still show the logo and text, even though it doesn’t have a URL, right?
   However, it’s not showing it at all.
 * If I do something like this:
 * `<a href="[if flag="wpcf-brand-website"][flag][/if]" class="inline">test</a>`
 * It breaks the loop and nothing shows up.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/empty-custom-fields-2/#post-4884186)
 * Hmm..I made the [if flag] so it only shows its content when there’s a field value.
   It shows nothing if the field is empty.
 * However, I see you still want to show something even when the field is empty.
   I wonder how that can be achieved.. I guess it will have to be another loop for
   when the field is empty?
 * I’m thinking of adding a new [if no_flag] function, so you can separate it like:
 *     ```
       [loop type="brand"..]
         <div class="team-member">
           [if flag="wpcf-brand-website"]
             <a href="[flag]" class="inline">
               [content field="image" size="thumbnail"]
             </a>
             <h4 class="light">
               <a href="[flag]" class="accent-color">
                 [content field="title"]
               </a>
             </h4>
           [/if]
   
           [if no_flag="wpcf-brand-website"]
             [content field="image" size="thumbnail"]
             <h4 class="light">
               [content field="title"]
             </h4>
           [/if]
         </div>
       [/loop]
       ```
   
 * So, I think I’ll implement this into the next update.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/empty-custom-fields-2/#post-4884187)
 * OK, please see the latest update to 0.9.0. I added [if no_flag] as in the example
   above.
 *  Thread Starter [openboxstudios](https://wordpress.org/support/users/openboxstudios/)
 * (@openboxstudios)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/empty-custom-fields-2/#post-4884191)
 * Perfect! When I get done with this beast of a project, I’m going to dedicate 
   some time, if you’d like, to helping figure out a pagination solution. Thanks
   again for the prompt responses and quick action, it is very much appreciated!
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/empty-custom-fields-2/#post-4884214)
 * Great, I’m glad the solution worked for you. I think this function to check for
   an empty field will be useful, for situations as you mentioned like carousel,
   links, etc.
 * As for the pagination feature, just this week I’ve been working on jQuery pagination,
   so the bulk of it is completed. I believe I’ll build it further to be able to
   integrate with the **[loop]** shortcode. I’m thinking of releasing it as an add-
   on – if you’re interested in testing it out, please send me an e-mail: miyarakira(
   at)gmail.com, and I’ll let you know when it’s ready.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Empty custom fields.’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/empty-custom-fields-2/#post-4884214)
 * Status: resolved