admin管理员组文章数量:1199762
I am looking for a function to add
<body onload="prepareFrame('https://airtable embed URL here')">
to certain wordpress pages only.
I know how to add a custom body class but not an onload statement.
add_filter('body_class', 'custom_body_class');
function custom_body_class($classes) {
global $post;
if ($post->ID == 346) {
$classes[] = 'services';
}
return $classes;
}
I am looking for a function to add
<body onload="prepareFrame('https://airtable embed URL here')">
to certain wordpress pages only.
I know how to add a custom body class but not an onload statement.
add_filter('body_class', 'custom_body_class');
function custom_body_class($classes) {
global $post;
if ($post->ID == 346) {
$classes[] = 'services';
}
return $classes;
}
Share
Improve this question
asked May 4, 2022 at 17:10
JoaMikaJoaMika
6986 gold badges27 silver badges58 bronze badges
1 Answer
Reset to default 0You could use the body_class
filter to add additional attributes. I'm not sure if this is the best option out there. Maybe javascript would be better for this.
function my_add_body_attribute($classes) {
echo 'onload="doyourthing" ';
return $classes;
}
add_filter('body_class', 'my_add_body_attribute');
本文标签: phpAdding onload to body for certain pages
版权声明:本文标题:php - Adding onload to body for certain pages 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738601590a2102098.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论