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>
endwhileI’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).
https://www.ads-software.com/extend/plugins/wck-custom-fields-and-custom-post-types-creator/
- The topic ‘Build loop based on custom field value.’ is closed to new replies.