admin管理员组文章数量:1302419
I am building a WordPress website using the Astra theme, and I noticed that meta and link tags in my site's head section contain closing slashes, like this:
<meta name="description" content="Example description" />
<link rel="canonical" href="/" />
I would like to remove the closing slash so that the tags appear as follows:
<meta name="description" content="Example description">
<link rel="canonical" href=";>
How can I achieve this in WordPress? Is there a filter or function that can modify the output of these tags? Or is there a plugin that allows customization of how meta and link tags are generated?
Any guidance would be appreciated. Thank you!
I tried using the following code in functions.php, but I am not entirely satisfied with this solution:
function fix_self_closing_tags($buffer) {
return str_replace(' />', '>', $buffer);
}
function start_buffer() {
ob_start('fix_self_closing_tags');
}
function end_buffer() {
if (ob_get_length()) ob_end_flush();
}
add_action('template_redirect', 'start_buffer');
add_action('shutdown', 'end_buffer');
本文标签: phpHow to Remove the Closing Slash from Meta and Link Tags in WordPress (Astra Theme)Stack Overflow
版权声明:本文标题:php - How to Remove the Closing Slash from Meta and Link Tags in WordPress (Astra Theme) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741700286a2393246.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论