How do I implement or install the particles.js
into wordpress?
.js/
I have tried install the particle.js but doesn't work, maybe i miss located some important details.
I also tried the "particles login page" plugin, then try to copy it into the content page, but still no luck.
Any suggestion will be a great help
Thanks.
How do I implement or install the particles.js
into wordpress?
http://vincentgarreau./particles.js/
I have tried install the particle.js but doesn't work, maybe i miss located some important details.
I also tried the "particles login page" plugin, then try to copy it into the content page, but still no luck.
Any suggestion will be a great help
Thanks.
Share Improve this question edited Nov 13, 2015 at 8:17 JiTHiN 6,5885 gold badges44 silver badges70 bronze badges asked Nov 13, 2015 at 7:43 Urei JaUrei Ja 991 silver badge2 bronze badges 1- Were you able to get it working in wordpress. I am having the same issues of it not working. I loaded/equeued the particle.js but it still not working. – Joseph Commented Jan 6, 2017 at 15:35
2 Answers
Reset to default 1You can enqueue a trustworthy CDN if you are not in a position to install it locally.
The following is to be added to your functions.php if you have a standard wordpress architecture.
function enqueue_particlejs(){
wp_enqueue_script('particle-js','https://cdn.jsdelivr/npm/[email protected]/particles.min.js');
}
add_action('wp_enqueue_scripts', 'enqueue_particlejs');
Then you'd need to use their way of actually triggering it on page, which means assigning an id of "particle-js" to one of your dom elements.
<div id="particle-js"></div>
If you don't have access to the javascript files then you can get away inlining it:
<script>
particlesJS.load('particle-js', '<?= get_template_directory_uri() . '/assets/particlejs.json' ?>', function() {
});
</script>
You'll need to create a particlejs.json file somewhere in your wordpress directory and reference it above.
They give one as example or just export one from the website you linked.
There are several methods to do the same. I'm describing how you should do it in the standard way. Upload the particles.js to your active theme folder ( I uploaded it to 'js' folder inside theme director. Open up functions.php in your active theme and insert following code.
function load_my_scripts(){
wp_enqueue_script('muaw-ajax', get_template_directory_uri().'/js/particles.js');
}
add_action('wp_enqueue_scripts', 'load_my_scripts');
Save the changes you made to functions.php, then it should be included to your theme.