First, don’t put script tags directly in template files, enqueue them from your theme/child theme’s functions.php
. Second, use the API to output URIs for scripts, don’t hardcode or use relative paths.
function wpdocs_theme_name_scripts() {
wp_enqueue_script(
'flexslider',
get_template_directory_uri() . '/js/jquery.flexslider.js',
array('jquery'),
null,
true
);
wp_enqueue_script(
'fancyselect',
get_template_directory_uri() . '/js/fancySelect.js',
array('jquery'),
null,
true
);
wp_enqueue_script(
'myscript',
get_template_directory_uri() . '/js/script.js',
array('jquery'),
null,
true
);
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );
Related Posts:
- Where to get information about array fields in $_REQUEST?
- WordPress URL Rewrite not working
- Namespacing WordPress project according to FIG standards
- Redirect to Page after Post Submit
- wp_remote_get returns an error for valid URL
- automated tests as a user?
- WordPress Wysiwyg Content not being displayed
- New Plugin Review
- Create custom blocks for bootstrap
- How to get the post_id from postmeta
- Problems with function on function.php
- Want to create Child theme, but already edited Parent theme css files and some php files
- Adding code to child theme functions.php to override parent theme behaviour doesn’t work
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- WordPress: Remove link in the_tags
- Set WP_MAX_MEMORY_LIMIT higher than PHP.ini memory_limit
- Custom category code not showing all posts
- Displaying NextGen Gallery using value from meta not working
- WordPress Scheduled Event Request Blocking
- jQuery not defined
- dynamic page in WordPress
- Apache Fallback instead of add_rewrite_rule
- Correct folder permissions?
- Link posts to pages for breadcrumbs
- Pagination of custom mysql in wordpress
- WordPress wpform plugin submit and get multiple checked value from checkbox [closed]
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Script to browser problem PHP
- wp_nav_menu returns menu list in ascending order. How can I arrange the menu same as dashboard menu
- How can I add extra word in permalink when someone click download button?
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- How to retrieve the sender email with wp_mail()?
- Why WordPress won’t update via VPN?
- WordPress update_post_meta updating with empty meta_value field [closed]
- Create custom permalinks to show Custom Post Type’s relationship?
- Call to undefined function mysql_connect() After upgrading PHP 7.1 to 7.3
- Add user ID to woocommerce customer dashboard
- Converting Y-m-d to a date with a Month name? [closed]
- Content filter won’t work
- How to retrive the text : No movie by this actor
- Is the 404 page automatically displayed if a loop returns nothing?
- update_post_meta only updating on last loop of foreach
- Link blogname and blogdescription to the Options Framework
- Why does the post_type_link hook everything twice?
- Adding conditional text to a PHP Shortcode Template
- Get related product based on subcategory selected from category id with ID 142
- wp_nav_menu not working correctly in my underscores theme
- use loop to return blog details
- PHP error when using newer PHP versions
- Customizer: How to change Header Image description
- Fetching Initials of the Commentator in the WordPress Website
- fetch woocommerce product with custom taxonomy
- WP_Query with AJAX returning empty array
- How to add post meta in while loop?
- PHP Helper Class to create shortcodes
- How can I Use 2 databases with one WordPress install
- How to set a featured image (thumbnail) with PHP?
- Output custom text field as unordered list
- Using Conditionals when homepage is a page and blog is /blog
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- Can not call .php files after switching to %postname%
- Checking page before applying image restrictions while uploading
- WP Container Displaying Only on First Page of Archive
- AWS Lightsail WordPress – connect to database on instance using mysqli
- Update Images after edit via php
- Drop down question
- Using wpdb to connect to a different database is not working
- custom mailchimp form using HTTP API
- how to use 2 index.php file One for mobile and one for desktop
- ACF under category name in shop page [closed]
- Accordion headings cuts off to second line on collapsing a accordion heading (used acf repeater)
- Using $this with an anonymous function in filters
- WordPress Recent Posts – Loop
- Changing default WPMU emails to be send thorugh Campaign Monitor Transactional emails
- Can’t add to time? [closed]
- Dynamic_sidebar load in string makeup
- Post Meta statement?
- not able to access $_POST on backend profile update
- WordPress Single Post Pagination Numbered and Navigational
- Displaying 3 Category Posts differently
- Add disclaimer before certain posts and pages
- Use Custiomizer to setup meta theme color tag
- I changed the password for the database user of my website, updated wp-config.php and wordpress asks to be reinstalled
- Click to expand menu
- Post formating on Home page
- Category – “No content found”
- Using ‘array’ method in wp_nav_menu causes it to disappear
- How can I correctly POST to a WordPress page?
- WordPress – Image href for home menu nav not working
- Search box background on a different page template
- How to add together (get the sum) a field from all author’s posts
- two body tags on all WP pages regardless of theme
- Load php function with AJAX on modal window
- Hide page title
- Edit Image/Image Details – Replace button missing
- Display biography post for today’s birthday person
- get user role. parameter id return type string [closed]
- Edit Error Page style
- PHP $_SESSION array – only showing current index
- How can I use AJAX in child theme template?