Guest User

Untitled

a guest
Feb 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. /* IN YOUR TEMPLATE FILE ABOVE THE HEADER CALL */
  2.  
  3. add_action( 'body_class', 'add_my_bodyclass');
  4. function add_my_bodyclass( $classes ) {
  5.  
  6. global $post;
  7. $condition = get_post_meta( $post->ID, 'METABOX_ID', true );
  8.  
  9. // Some condition to compare / check
  10. if ( ! EMPTY( $conditon ) ) :
  11. $classes[] = 'CUSTOM_CLASS';
  12. endif;
  13. $classes[] = '';
  14.  
  15. return $classes;
  16. }
  17.  
  18.  
  19. /* THEN IN THE ENQUE FUNCTION */
  20.  
  21. $classes = get_body_class(); // Check body classes must be included
  22.  
  23. if ( in_array('CUSTOM_CLASS', $classes) ) :
  24. wp_enqueue_script( 'video', get_template_directory_uri() . '/assets/js/jquery.background-video.js', array( 'jquery' ), '1.0.0', true );
  25. endif;
Add Comment
Please, Sign In to add comment