Add delay before executing PHP function

I would like to add a Class called “snap” to the tag only on two templates (the front page and on my single Custom Post Type page ‘projects’).

To do that I don’t have any problem. But I also would like to add a delay of 2 seconds before executing the function. And that, is what I struggling with.

Here is the code to add the Class “snap” in my function.php :

add_filter( ‘body_class’, ‘update_body_class’);
function update_body_class( $classes ) {
if ( is_front_page() || is_singular(‘projects’) )
$classes[] = ‘snap’;
return $classes;
}

Thanks for your help!

Read more here:: Add delay before executing PHP function

Leave a Reply

Your email address will not be published. Required fields are marked *