Adding onload to body for certain pages

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’);