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
- Importing data for advanced custom fields plugin?
- Gutenberg add a custom metabox to default blocks
- Filter post listing by meta value which is a date
- Extra profile field as select box?
- Matching Serialized Arrays with meta_query
- Pre-filling custom fields on New Post
- Make Custom Field Into A Link On The Front End?
- How to activate “custom fields” section in WP3
- Why isn’t my code to save custom fields in quick edit working?
- How to oEmbed from custom field, responsive to container size and responsive
- How to use multiple query with same meta key
- Custom Meta Boxes: Store two values in one repeatable field
- Custom fields won’t display on my blog page
- How to customize default wordpress editor?
- Problem in custom meta boxes
- Add an advert every nth Paragraph
- Undefined index error when saving content on metabox
- Metabox with multiple fields added by user and upload box
- Use ajax to update_post_meta
- How to update custom user meta field in wp?
- Get all meta keys assigned to a post type
- sort search results by custom fields using dropdown
- tracking number field in Woocommerce order [closed]
- Add conditional custom option to ‘Display name publicly as’ dropdown
- Custom fields not getting saved in the databse when added to the add new user profile page
- I want to send an email when each post is published
- Creating a widget with a number of custom fields
- How to Create Dynamic Fields in a Meta Box?
- Set front page option using custom fields?
- Add post meta fields, when creating a post using WordPress’ REST API
- Custom Field Values not updating unless I click “Update” twice
- Can I create a template or doctype for my blog site?
- Custom field, add class to anchor tag
- Custom Metabox additional item
- How to combine custom fields to make one order-able value
- Updating Other User’s Metadata
- get_posts in meta box dropdown not showing latest posts
- Trying to reorder posts by custom field
- Custom Query based on custom field of a single post
- Can’t save php string to a custom field
- comment meta_query for keys that aren’t yet set
- Link the retrieved custom field values to its respective posts
- Sortable custom field values from all posts on a page template
- How can I use custom properties to set different background on different pages?
- Values entered in a meta box aren’t saved
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- change order of images attached to post
- How to Make Post Custom Column Editable
- how can I show name and value of Custom Fields together?
- Adding simple (one button) Audio player using Custom Fields?
- tax query between operator like
- Including Custom fields within the_content
- How can i make a search box to search by custom field
- Single page WordPress website – custom fields or meta boxes or something else?
- Collect Data from NEXT item while in loop
- Order custom fields alphabetically
- Display Custom Field in Sidebar if Value is Present
- Is it possible to compare the current time with a custom “start” and “end date
- Custom fields array to display it monthly
- Gutenberg add a custom metabox to default blocks
- How to use ACF with javascript to update custom field values?
- Sum All the Post Meta of Published posts of Current Logged in user
- Show Custom field value instead of title in WP Menu
- How to add code to custom field to every blog post via php?
- Getting user’s data, by custom field lookup (meta)
- Counting number of images from loop
- Automatically set the_post_thumbnail to Custom Field Value
- Redirecting to an external URL
- php if, else & custom fields – syntax error
- Why is wp_list_pages altering $post->ID of the page?
- Related post thumbnail not showing up
- Edit different parts of a page seperately
- Copy url from post_content to custom field
- Custom fields: dropdown values depending on other custom field value
- How do i get a specific user metadata using custom metavalue outside of wordpress?
- Creating an If/Else statement using WPAlchemy MetaBox radio boxs
- How to retrive Custom Fields as Values for a Form field
- Custom fields doesnt work well with any postTAB plugin
- Colecting values from custom field checkboxes and displaying them in the post
- Build Array from Input Fields question
- Too many if’s and else if’s ?? – Must be better way [closed]
- Grouped Custom Meta Fields without plugin
- Google not index my Custom 404 page ?why?