You’re assigning a value to $dish
, but then not using it…
Try the following. It takes advantage of the fact that your image for “gluten” is named gluten.png
, etc. You’ll be able to add more tags by just adding to the $images
array.
$images = array(
"gluten" => "Gluten Free",
"vegan" => "Vegan Friendly",
"vegetarian" => "Vegetarian"
);
$dish_tags = (array) get_field('diet_friendly');
foreach ($images as $image_name => $alt) {
if (in_array($image_name, $dish_tags)) {
echo '<img src="' . get_template_directory_uri() . '/images/' .
$image_name . '.png" alt="' . $alt . '" />';
}
}
Related Posts:
- WooCommerce shop page to use my custom template [closed]
- Formatting ?
- Which theme foundry has clean coded themes, where code is poetry [closed]
- Don’t understand why theming is so strange and twisted [closed]
- Same ACF on two different pages
- get_page_template returning nothing
- WordPress get_template_part() function not working
- Dropdown filter by custom field
- How to escape html generate by a loop
- ACF Pro make URL Linked in Custom Template [closed]
- Where do you add code in custom fuctions so it works on a specific page?
- Running a function on post update with new post meta
- How to code custom special page
- ACF get_sub_field ALT TAG in the repeater doesn’t show
- restrain filter on get_the_excerpt to queried item in stead of current post
- wanted to sort the wp_query array by two ACF field (Year and month)
- Custom themes that won’t work when theme is changed
- New theme HTML5 Support for Search in WordPress 4.4
- DIV containing iframe disappears below break point of 992 in Oxygen Builder
- Website Developer has gone missing! How to gain full access of your code from a WordPress website?
- Is there a has_more_tag() method or equivalent?
- How to effectively reset the post object after calling get_posts()
- How to force Media manager to overwrite files of same name?
- How wp_cache is supposed to work, and does it help with performance?
- is_home() returns false on the home page! When is the home page NOT the home page?
- Custom attribute for the title tag with wp_title()
- What, specifically, should be included in theme_name_setup()?
- Enabling Widgets By Default in Custom Theme Development
- How to fix the error “file_get_contents was found in the file functions.php”?
- Identifying the priority of style.css so I can make a small CSS file load last
- WordPress Customize — Move “menus” options / field to another section
- How to use the responsive images feature from WP 4.4 in your themes
- Symlink a directory to wp-content/themes
- What are WooCommerce starter themes? [closed]
- Passing variable in hooks and filter
- How do I create a specific login page for a specific user?
- How do you protect a premium theme from being copied?
- How to support Lazy Loading Assets in a WordPress Theme?
- Convert PHP readfile to WP_Filesystem
- Wysiwyg editor for P2 theme
- Sub folder CSS that’s read by Admin panel
- Toggle Sidebar Display
- Dequeue a style file which is making website load slow!
- How to customize save function event?
- WordPress page templates in a directory
- Do I need normalize.css when developing my own WordPress-theme?
- How to float an image in Gutenberg
- Limit Loop to 5 Posts?
- Table of Contents Before first heading
- Theme-wide custom post template
- Bootstrap card columns change images size
- comment form args are not translatable (customized comment form)
- Zoom on custom theme without child
- What do with the index.php … [duplicate]
- How to add Space between sidebar and footer widget in WordPress theme [closed]
- Custom Navigation build using wp_nav_menu and walker
- Question regarding WP multisite feature
- Call to undefined function add_menu_page() on theme activation
- The Content is not Wraping in tag
- Updating a live theme safely?
- How do I remove inline style in featured image markup?
- different way to achive stylesheet_url
- Why is my CSS not loading?
- How to find default functions of wordpress
- How to remove ver from stylesheet URL? [duplicate]
- Using a starter theme vs starter theme with child theme
- How To Detect Posted Comment in Theme Development?
- Create a category archive page in TwentyTen Child Theme
- where is real values of variables?
- using Options Framework – can “theme-textdomain” domain be changed?
- How to add sidebar to Isola theme? [closed]
- How to remove WP Title Tag?
- Change the sidebar from left to right twentyfourteen theme
- Custom theme won’t use search.php
- Get attachment meta (I need attachment ID, unsure how to find it)
- Retrieve WordPress’ the_content() with jQuery
- Minimal WordPress Functionality on Existing Website
- W3 total cach and theme changes [closed]
- How to add testimonials with an image?
- How to setup sidebar modules to use jQuery Accordian
- How to copy page/post from one theme to another?
- Add class every 4 post like , class_1, class_2, class_3, class_4 and class_1, class_2, class_3, class_4
- Using has_term() function for category-subcategory structure
- Theme functions don’t work as expected in partial included via get_template_part() after custom query using Ajax [duplicate]
- Avoiding do_shortcode() loops
- WordPress Post Order
- Why content is not adding for each blog post
- Correct was to customise theme using get_theme_mod in scripts
- Recent post in the middle of the content
- How to figure out which wordpress theme a site was using?
- Best way to allow for extended use of WordPress functions inside single.php
- Flexslider not working for my custom theme WordPress
- Redirect to custom login page
- How to close open divs in post loop
- Display Today’s date outside the loop?
- How to Disable Color Options?
- Form to Add Posts to Custom Post Type (Again)
- Workflow of Collaboration on wordpress development [closed]
- How to make admin theme option with image slide show?
- Explanation of User Roles and Capabilities