[Solved] javascript is not running in wordpress


There are a few ways you can include JavaScript files in WordPress, I will give you one example using your child theme.

First you need to validate whether or not you actually have a child theme. Use FTP to login to you server and go to the wp-contents/themes directory. There you will see all your installed themes (in your case betheme). If you do not have a child theme follow these steps:

  1. Create a new directory in your themes folder (betheme-child).
  2. Upload your JavaScript file in this directory (for example script.js)
  3. Create a new file called functions.php and add the following code to it: (surrounded by php opening and closing tags):

add_action('wp_enqueue_scripts', 'enqueue_child_scripts');

function enqueue_child_scripts() {
    wp_enqueue_script('child-script', get_template_directory_uri() . '/script.js');
}
  1. Login to your wp-admin and navigate to your themes
  2. Enable your child theme instead of your normal theme.
  3. Go to the front-page of your website, look at the page source and check if your JavaScript file is being loaded.

solved javascript is not running in wordpress