logo
down
shadow

Theme Development: JavaScript not working when linked from functions.php


Theme Development: JavaScript not working when linked from functions.php

Content Index :

Theme Development: JavaScript not working when linked from functions.php
Tag : javascript , By : Marc Dong
Date : November 27 2020, 04:01 AM

like below fixes the issue You're not actually enqueuing any external scripts at all in your functions.php file. You need to reference the path to the file as the 2nd parameter of your wp_enqueue_script method.
get_template_directory_uri() simply tells the method to go to the root of your theme folder, it doesn't specify the javascript file that you're trying to enqueue. It should look more like this:
<?php

    function k9stormdomestictheme_script_enqueue() {
        wp_enqueue_style( 'style', get_stylesheet_uri() );
        wp_enqueue_script( 'script', get_template_directory_uri() . '*the-remaining-path-to-your-js-file*' );

    }

    add_action('wp_enqueue_scripts', 'k9stormdomestictheme_script_enqueue');

?>
<?php

    function k9stormdomestictheme_script_enqueue() {
        wp_enqueue_style( 'k9stormdomesticstyle', get_stylesheet_uri() );
        wp_enqueue_script( 'k9stormdomesticscript', get_stylesheet_uri() . '/js/script.js', array (), 1.1, true);
    }

    add_action('wp_enqueue_scripts', 'k9stormdomestictheme_script_enqueue');

?>

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Wordpress child theme template not working with external jquery/javascript functions


Tag : javascript , By : merten
Date : March 29 2020, 07:55 AM
To fix the issue you can do I have created a template in my wordpress child theme and included a link to Bootstrap v3.0.3 .js file which is also hosted on my site. , Can you try loading files like this?
function theme_enqueue_styles() {
    wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
    wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', array($parent_style));
}
add_action('wp_enqueue_scripts', 'theme_enqueue_styles');

function wpdocs_theme_name_scripts() {
    wp_enqueue_style( 'style-name', get_stylesheet_uri() );
    wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/vanja-script.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );

Is theme validation required for Bigcommerce's Stencil theme development


Tag : development , By : Sebastian Gift
Date : March 29 2020, 07:55 AM
This might help you It is, yes. But as a temporary solution while in development you can always add some entries to the .eslintignore file (as specified here) present in your root folder. You will have some already there for reference. That will be useful for plugins and modules not written by you that ESLint might not let pass. ;)

Add a section not working in Shopify Theme development


Tag : development , By : anov
Date : March 29 2020, 07:55 AM
should help you out Figured it out! Every section has to have a preset in the {% schema %} otherwise it will not show up in the add a section area.
You put {{ content_for_index }} in the index.liquid file and your preset in the {% schema %} of yoursection.liquid
"presets": [
{
"name": "Collection Carousel",
"category": "Carousel",
"settings": { 

}
}
]

I want to know about translation functions in theme development


Tag : php , By : Ansari
Date : March 29 2020, 07:55 AM
this will help For default, you don't need to use translate function. If you want you can translate them also. Value for default should be a string. You will find how to make a string translatable within those links mentioned below and you will get a clear idea on WordPress translation.
value of default doesn't initially store on DB.

functions not working well when linked via a static lib, but working if copied in the prog


Tag : c , By : Simon Hogg
Date : December 23 2020, 05:30 PM
Any of those help I have a static lib (.a) containing some useful functions that I'm using inside another program. The link goes well, the functions from the lib are found, but when the program gets executed it doesn't work well. On the other hand, if I copy/paste the lib functions I need directly in my program code, it works well. Moreover, it was working well on win32, but now I'm on Win64. , There are multiple issues in the code fragments posted:
int readFile(const char *filename, UI8 **Params, I64 *ParamsLen);
Related Posts Related QUESTIONS :
  • showDialogPopup Refresh Page after Click
  • Child component does not set the initial value passed from the parent: ReactJS
  • Nodejs javascript added to button not responding
  • Trying to define a promise.all
  • Python GEE to extract featurecollection timeseries from Landsat imageries
  • How to write negative binary number?
  • Unable to set property of individual object
  • Why Named Function Expression itself cannot assign Name to another Value?
  • How to reset scroll position on single page pagination
  • How to scroll to bottom of page, when a new message is sent - Socket.io
  • How to reconstruct audio blob from a base64 encoded String?
  • How to calculate numbers within an array of objects
  • Using JavaScript to change CSS properties of SVG circles for all circles that was not clicked
  • Is there value in propTypeing repeat required properties at every level of nested components?
  • Call function if variable does not exist in a filter
  • localStorage value doesn't get updated automatically
  • React not updating state with setState correctly inside promises
  • Direct native JavaScript or jQuery method to get containing block of an element
  • Dynamic JSON object to Html Table
  • How to send Id and file to same controller?
  • How to Make a jQuery Table Cell(td) clickable to Run a Function?
  • Prevent the duplicate function onchange event jQuery
  • Reactjs Input Upload doesn't return local URL
  • An unexpected 'StartObject' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected
  • How to filter a JSON Array, with an eventListener input value at keyup
  • How to separate the different properties of filter in css?
  • Why dont work change event of bootstrap input spinner?
  • How to hide overflow text content in react
  • Is there another way to write line 6
  • Cypress - how to find by text content?
  • How to setstate for the dynamic checkboxes in a loop in react?
  • Is display:none safe?
  • How to create a form to change part of a href url of a button?
  • Put many function inside function in Javascript
  • how to exit from loop after a ajax call
  • Do Angular Reactive Form Validator.min/max check Perform Type Conversions before checking the value?
  • How to Replace Text Within Script Tags Using JQuery
  • add variable to object if not undefined using short-hand
  • How can I effectively curve my items inside a list?
  • Add new record Keyboard Shortcut on Kendo Grid Mvc
  • Time and Date running on page
  • Looping through page links puppeteer doesn't return values from the newly loaded page
  • Problem with Navigator.geoLocation.getCurrentPosition not working
  • Trying to change the id of an element with Javascript
  • Embedded Schema Inserting Blank in Meteor using Collection2
  • avoid useEffect to render at first load?
  • Why is this CSS transition only working correctly on the some clicks? How to solve it?
  • Interpolated values does not reflect the latest values in an Angular app
  • Javascript classes define attribute in constructor or outside the class
  • How to block scroll event passing through to iframe until iframe is active?
  • What is the purpose of "constructor" method in javascript?
  • Stencil JS not working with non-default imports
  • Are frameworks misleadingly named for marketing purposes?
  • React <Redirect> after transition not working
  • How to send multiple parameters in a function using EJS
  • React conditional style on custom click
  • Push a block of information to an array X times based on an external variable
  • How do I populate dropdown with names, and values (numeric ids)?
  • How to apply styling to elements created with .insertAdjacentHtml method
  • Positioning key:value of an object
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com