• The CSS Regions Polyfill javascript asks that one set up a web page with both script and HTML. Can this be done using WordPress?

    Or do I need to do it using a text editor? If that’s the case, where do I put it under the WordPress installation?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @mythusmage,

    Yes you can do it with WordPress.

    I have recently answered in the WordPress forum on how to add Javascript on your page/post. You can read my answer here.

    Similarly, you can add styles to a page/post using the following method.

    
    wp_enqueue_style( string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, string $media = 'all' )
    
    
    /**
     * Proper way to enqueue scripts and styles
     */
    function wpdocs_theme_name_scripts() {
        wp_enqueue_style( 'style-name', get_stylesheet_uri() );
        wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
    }
    add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
    

    Additionally, you can is_page() method with parameters to identify a particular page and enqueue scripts/styles based on a page. WordPress Codex has good documentation on is_page and that should help you.

    Thread Starter mythusmage

    (@mythusmage)

    Something tells me we need a plugin for this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can I’ is closed to new replies.