Having issues with creating subtheme or enquing any js/css in function.php - Acme Themes

Best Premium and Free WordPress Themes Forums SuperMagPro Having issues with creating subtheme or enquing any js/css in function.php

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #4795
    foot01
    Member

    Hi,

    My client bought this theme and I have a few problems with loading css / js

    I’ve been trying several ways to make subtheme…
    And I couldn’t find a way to load a style-subtheme.css without squashing theme style.css
    So I gave up and stared hacking directly in the theme… uggly (I rely on git… oufff)

    now I’ve had to create a widget and I hit again the same issue when I need to load a js.

    I’ve added this in function.php but doesn’t seem to do anything

    function widget_filinfo_load_js()
    {

    // Register the script like this for a theme:
    wp_register_script( ‘filinfo-script’, get_template_directory_uri() . ‘/filinfo/filinfo.js’, array( ‘jquery’ ) );
    }
    add_action( ‘wp_enqueue_scripts’, ‘widget_filinfo_load_js’ );

    Thanks for your help

    Regards

    Antony

    #4797
    acmesupports
    Moderator

    Hello,
    Thank you so much for using our theme SuperMagPro. Some line of code is mistake there. So please use the below code while enqueue style and scripts.

    add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
    function theme_enqueue_styles() {
    wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
    wp_enqueue_script( ‘child-custom-js’, get_stylesheet_directory_uri() . ‘/child-custom.js’, array(‘jquery’), false, ‘1.0.0’ );
    }

    If you feel any problem, please feel free to ask.

    Best Regards,
    Acme Supports

    #4796
    foot01
    Member

    I finally figured out a solution

    by using wp_enqueue_script in place of wp_register_script

    it seems to work fine

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.