admin管理员组文章数量:1426066
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?
本文标签: customizationNeed to replace some text string on a title
版权声明:本文标题:customization - Need to replace some text string on a title 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745466252a2659545.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论