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;

1 Answer 1


You 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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.