Support » Developing with WordPress » Wanting to use Particle JS

  • Hi… Not sure if this is an appropriate forum… I’m not looking for anyone to do anything specific… Just looking for clarification. This is outside my theme I believe and pertains to core wpress function.

    I am trying to modify the background call to use particle.js instead, but I’m not sure where custom-background gets stored, and nor do I understand where I would find the backend piece that contains the front-end output code… It’s hard to word this, because I am a novice.

    But I see this function

    		// Set up the WordPress core custom background feature.
    		add_theme_support( 'custom-background', apply_filters( 'hostiko_custom_background_args', array(
    			'default-color' => 'ffffff',
    			'default-image' => '',
    		) ) );

    And I understand that this function allows the theme to set the “custom-background” core feature, and I know that this is affected by custom-background-css

    But I don’t understand much more than that.

    Basically I am looking for a nod in the right direction.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Is this a core wordpress thing? Will I break stuff trying to modify it?

    This is controlled from the customizer. Please login to dashboard and visit the front page you will see customizer on the top bar black strip.

    No, I get that… I want to override it. I want to draw the background with particle.js

    Moderator bcworkz


    Never alter core files. You won’t necessarily break anything, but in the long run it just isn’t worth it. You have to keep reapplying your changes after every update. The core part of the custom background provides the customizer interface, but it’s up to your theme to display the selected background. This feature is to allow users to select an image or video as background. Because particles.js dynamically draws the animation, I don’t think any of the existing background feature is going to help you.

    You basically need to alter your theme to display particle.js output instead of the normal background feature. To prevent conflicts, it may be a good idea to remove background theme support. You could provide a UI to specify particle parameters, but get it working first before trying anything fancy.

    For the same reasons you should not modify core files, you should not modify theme files as well. To implement custom code, the best option is often to create a child theme. Copy to your child theme, your parent theme’s template file(s) that outputs the part of the page where you want the particles container to appear. Edit the output as needed to include the particles container.

    In the child theme’s functions.php, use wp_enqueue_script() to load the particles.js library and the .js file containing the particlesJS() call where all the parameters are set. Add all needed CSS to the child’s style.css.

    Thank you =) This was informative, so I should write it into a child theme, perfect I am already using one. I guess I just now have to read the theme a bit more thoroughly and study particles.js a bit 🙂 I already have them set in the queue via functions.php

    I will report back once I figure it out, so this thread may be of service to someone else.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Wanting to use Particle JS’ is closed to new replies.