Title: Build loop based on custom field value.
Last modified: August 21, 2016

---

# Build loop based on custom field value.

 *  [jrhalchak](https://wordpress.org/support/users/jrhalchak/)
 * (@jrhalchak)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/build-loop-based-on-custom-field-value/)
 * I’m trying to create a loop with a sub-loop. The idea is that this site, which
   has company partners, will list out their partners. These partners have the option
   of paying the site-owner to be featured.
 * So the post-listing will have all the featured members at the top and the rest
   below it.
 * So (pseudo-code) I want to have a loop that says
    while while – featured_checkbox
   = yes, have_posts … <featured box> endwhile
 *  <regular box>
    endwhile
 * I’m not sure how to check the value of elements in the multidimensional array
   thought because the get_post_meta serves up the parent array.
 * Here’s a snippet of what I’m doing inside the 1 loop I have currently:
 *     ```
       $feat_company_info = get_post_meta( get_the_ID(), 'featured-company-info', true );
           foreach( $feat_company_info as $f_info_items){
               $mc_featured = $f_info_items['is-featured'];
               $mc_contact = $f_info_items['contact-name'];
               $mc_website = $f_info_items['website'];
               $mc_email = $f_info_items['email'];
               $mc_description = $f_info_items['description-of-services'];
           }
       ```
   
 * I want to check that $mc_featured value when creating my loops (and later so 
   I know not to add those fields if it’s not set).
 * [http://wordpress.org/extend/plugins/wck-custom-fields-and-custom-post-types-creator/](http://wordpress.org/extend/plugins/wck-custom-fields-and-custom-post-types-creator/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [jrhalchak](https://wordpress.org/support/users/jrhalchak/)
 * (@jrhalchak)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/build-loop-based-on-custom-field-value/#post-3908532)
 * Also, I have an additional meta-box for non-featured companies. The featured 
   fields are separate so that the info can be maintained even if the company is
   no longer featured.

Viewing 1 replies (of 1 total)

The topic ‘Build loop based on custom field value.’ is closed to new replies.

 * ![](https://ps.w.org/wck-custom-fields-and-custom-post-types-creator/assets/icon-
   256x256.png?rev=2257602)
 * [Custom Post Types and Custom Fields creator - WCK](https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/)
 * [Active Topics](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wck-custom-fields-and-custom-post-types-creator/reviews/)

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [custom loop](https://wordpress.org/support/topic-tag/custom-loop/)
 * [loops](https://wordpress.org/support/topic-tag/loops/)
 * [WCK](https://wordpress.org/support/topic-tag/wck/)

 * 1 reply
 * 1 participant
 * Last reply from: [jrhalchak](https://wordpress.org/support/users/jrhalchak/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/build-loop-based-on-custom-field-value/#post-3908532)
 * Status: not resolved