php - Add Codepen animation as Preloader to WordPress

I found a CSS animation snippet on Codepen, and would like to add it in my WordPress site for preloader animation. I hav

I found a CSS animation snippet on Codepen, and would like to add it in my WordPress site for preloader animation.

I have seen similar question being asked on here , but I couldn't resolve this from the available information there. I want to know:

1) In which location should I add the codepen html code?

2) In which location should I add given CSS?

3) And in which location should I add any required JS to make it work like it happens here?

I found a CSS animation snippet on Codepen, and would like to add it in my WordPress site for preloader animation.

I have seen similar question being asked on here , but I couldn't resolve this from the available information there. I want to know:

1) In which location should I add the codepen html code?

2) In which location should I add given CSS?

3) And in which location should I add any required JS to make it work like it happens here?

Share Improve this question edited Apr 29, 2019 at 7:28 Vishwa 3762 silver badges17 bronze badges asked Apr 28, 2019 at 12:40 Aishwarya DwivediAishwarya Dwivedi 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 2

1) In which location should I add the codepen html code?

If you're using a child theme, then for example, you could copy parent theme header.php file to your child theme directory and add the required html to that file after <head>.

If you're developing your own theme, then put the markup wherever you want on.

Or you could also add the markup with an action hook (e.g. wp_footer or theme specific action hook, if available). This could be added to your theme's functions.php file or a custom plugin file. Something along these lines,

add_action( 'wp_footer', 'prefix_my_preloader' ); // or other suitable template hook
function prefix_my_preloader() {
  ?>
    <div id="cooking">
      <!-- rest of the markup -->
    </div>
  <?php
}

2) In which location should I add given CSS?

Styles can be added either to your (child) theme's styles.css file, Customizer's Additional css section (if available, but maybe not the best option), or a custom css file that is located either in your (child) theme or custom plugin directory. Remeber to include the styles if you're using a custom css file.

3) And in which location should I add any required JS to make it work like it happens here

Scripts can be added either to your (child) theme's scripts.js file or a custom js file that is located either in your (child) theme or custom plugin directory. Remeber to include the scripts if you're using a custom js file.

P.S You can also add the styles and scripts with custom functions using action hooks as mentioned on the accepted answer for Add CSS animation as Preloader to WordPress. You would then add these functions either to your (child) theme's functions.php or a custom plugin file.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745542521a4632192.html

相关推荐

  • php - Add Codepen animation as Preloader to WordPress

    I found a CSS animation snippet on Codepen, and would like to add it in my WordPress site for preloader animation. I hav

    20小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信