we are using Bridge theme in Wordpress as a basis for a restaurant menu. This menu has titles of food that in the plugin template (restaurant-menu-list-item.php) are called to be printed on the screen like this:
<div class="qode-rml-title-holder">
<<?php echo esc_attr($restaurant_menu_item_title_tag)?> class="qode-rml-title">
<?php esc_html(the_title()); ?>
</<?php echo esc_attr($restaurant_menu_item_title_tag)?>>
</div>
We want to have icons together with the titles so that if we write a food name called "Chicken Stew [veryspicy]" that part that is marked "[veryspicy]" becomes two small icons of chili (png image).
We have made this code below and it works in WP body text but not in this part of the restaurant menu. We wonder if the "esc_html(the_title());" somehow blocks it or what is the reason.
//Spicy marks in the menu
function replace_text_wps($text){
$replace = array(
// 'WORD TO REPLACE' => 'REPLACED WITH THIS'
'[spicy]' => '<img alt="Hot food" src=".png" style="width: 31px; height: 25px;">',
'[veryspicy]' => '<img alt="Very hot food" src=".png" style="width: 31px; height: 25px;"><img alt="Very hot food" src=".png" style="width: 31px; height: 25px;">'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_content', 'replace_text_wps');
This code we have put into the functions.php of the theme. Tried to also to put it in the restaurant menu plugin file but the menu stopped to work like that. So, it does work on the website on a normal page as a body text but it doesn't work inside this restaurant menu plugin that prints the title and the description of the food from a form filled in the admin. How could we get it working?