I would first loop over $lista
and generate a new array of data that only has non-empty values. Now you can check $values
to ensure there is data and output your title:
function opening_hours_custom_fields() {
global $post;
if ( $lista = genesis_get_custom_field( '_happy_day', $post->ID ) ) {
$values = array();
foreach ( $lista as $value ) {
if ( $value != '' )
$values[] = $value;
}
if ( $values ) {
echo '<h3>Happy Day</h3>';
echo '<ul>';
foreach ( $values as $value )
echo "<li>$value</li>";
echo '</ul>';
}
}
}
Related Posts:
- Add a Jquery Datepicker to custom field in post edit
- Correct Approach for Validating Custom Field Input
- Auto-add paragraphs to custom field?
- Displaying Custom Fields on Post with Genesis Child Theme
- get_post_meta not working inside loop
- Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]
- Custom Fields Code not echoing whats in the value field
- add_action and remove_action if custom field exists
- Meta Box Plugin Cloned Fields – Multiple Foreach values
- Display metabox title for custom fields with values
- simple fields plugin custom query
- author.php not showing content if Author has no Posts
- How do I use foreach to get content from a custom-field in multiple posts?
- Show message if statement is false – foreach
- Retrieve IDs from custom field, count and display results differently according to count
- Foreach giving one too many list items, how can I remove the last empty line?
- Query posts by Custom Meta (checkbox) & Genesis Grid Loop
- Adding function to Genesis genesis_header [closed]
- Button inside Custom Meta Box triggering the Update Button
- Why is my Custom Meta Box Field Inputs NOT saving?
- Filter multiple custom fields Values with Check boxes
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- Get registered custom fields or post meta even if empty
- Alter main archive, to show posts with meta as last
- Add microdata from schema.org [closed]
- Customizing user data
- Displaying multiple URLs as custom field values
- Add additional ‘description’ field for defined roles / role metadata?
- Can’t display errors in attachment_fields_to_save
- Change the main loop WordPress impact on the server?
- How to get categories with posts by custom field value?
- How to load an assets based on custom field value?
- displaying and sorting comments by a custom field (using PODS plugin) [closed]
- Meta Query returns wrong number of posts
- Declaring in variables [closed]
- Pass current post title to a predefined link
- auto-populating custom nav with all items from custom post type
- How to hide a custom field if there is not a value
- Adding auto-complete to custom gravity field not working
- how to display a widget only on a page where the custom field is defined?
- Show values of custom post meta on ‘Add new post’ page?
- custom-meta-box checkboxes from loop won’t save
- Custom dropdown field added to media gallery; how to get it to save properly?
- Can I create a template or doctype for my blog site?
- Sort custom post type by multiple custom fields
- Custom field, add class to anchor tag
- Custom post meta field effect on the performance on the post
- Set post to unpublished after one week depending on condition
- How to find a post using XML-RPC without knowing ID
- Insert a custom field into a shortcode and use it in post(s)
- Is it possible to create a post from an NextGen Gallery image?
- How to get latest post value if first post is empty in wordpress
- Sort alphabetically by custom field
- How to add a custom field in the advanced menu properties?
- More efficient to add content to custom fields or the content area?
- Add / Update Custom Fields After Select Pictures in Media Window
- Getting Custom Fields from WordPress JSON API [closed]
- Display URL in a Custom Field
- How do i add custom fields to my themes template file?
- Custom Field to a Role?
- Linking Custom Fields to Database Records
- conditional logic for front-end custom field edits
- Trying to sort and display categories(not posts) by custom field: ‘order’
- How to show a post if was published less than two hours ago?
- List users by sum of all their posts’ custom field values
- Custom field as Slug
- How to save the date/time of last update of an extra user profile field?
- How to populate custom field dropdown box based on prior selection?
- Custom tables or custom fields?
- Collect user custom field in product page woocommerce
- Saving Custom Field Data before Publish
- Search in Archive Pages by subcategory, tag, custom field and year
- display custom field from inner blog in the main homepage of wordpress multisite
- Post selector as Custom Field
- Custom WP_Query for WordPress Search Results with meta_query
- Change order of posts
- Trying to retrieve post meta
- Multiple URLS per post non-ascii
- Custom Metabox additional item
- Meta Query And/Or
- Migrating old posts to new wp, how to extrapolate infos from the post body to custom fields?
- $form_fields from attachment_fields_to_edit returning empty array
- How to combine custom fields to make one order-able value
- How to link keywords in custom fields?
- Updating Other User’s Metadata
- get_posts in meta box dropdown not showing latest posts
- Displaying custom field according to date
- URL Rewrite fires when retrieving a custom value?
- Trying to reorder posts by custom field
- Uploading PDF using Media Uploader
- Add first url to custom field on publish_post
- Use meta_query to get title of associated post
- Delete custom fields when deleting posts
- Limits, not all post are showen when querying for posts by view count
- Meta query with multiple custom fields for archives page ordering problem
- Why orderbyb meta_value_num won’t affect the generated SQL Query order?
- Custom fields attached to a page template only show on edit screen when page is saved
- filter custom field values $min $max
- Custom field query without duplicates results
- Automatic Shortcode Creation with Custom Fields [closed]