0
votes

I converted static HTML template into php for WordPress successfully. The issue is Html template had few Jquery plugins for slider, testimonial, owl carousel & some other javascript min.js, which fails to load in the browser. I tried adding

<?php wp_enqueue_script('jquery'); ?>

for jquery and then

<script src="<?php bloginfo( 'template_url' ); ?>/js/jquery-1.12.4.min.js" type="text/javascript"></script>  
<script src="<?php bloginfo( 'template_url' ); ?>/js/plugin/jquery.easing.js" type="text/javascript"></script> 
<script src="<?php bloginfo( 'template_url' ); ?>/js/jquery-ui.js" type="text/javascript"></script>

many scripts are there like this but all that fails. Even the slider, which is given below

<!--Main Slider-->
<link href="<?php bloginfo( 'template_url' ); ?>/template-parts/css/settings.css" type="text/css" rel="stylesheet" media="screen">
<link href="<?php bloginfo( 'template_url' ); ?>/template-parts/css/layers.css" type="text/css" rel="stylesheet" media="screen">
<link href="<?php bloginfo( 'template_url' ); ?>/template-parts/css/style.css" rel="stylesheet" type="text/css">
<link href="<?php bloginfo( 'template_url' ); ?>/template-parts/css/responsive.css" rel="stylesheet" type="text/css">

<!--Theme Color-->
<link href="<?php bloginfo( 'template_url' ); ?>/template-parts/css/theme-color/default.css" rel="stylesheet" id="theme-color" type="text/css">

Even the default font size of text in footer has changed to small after editing text in wordpress footer.php file. Menu in header doesn't have that hover effect as it was in tempate.error log snippet

2

2 Answers

0
votes

Use function to call the css and js.for backend use admin_enque_script and wp_enque script.and please use register function to call css and js before to call the files

0
votes

The best way to link external css and js files to wordpress is enqueue them in functions.php file.

Below is given example:

<!-- Html css link in your header.php or footer.php file -->
<script src="js/plugin/jquery.easing.js" type="text/javascript"></script>

what you should write in your functions.php

<?php
wp_enqueue('jquery'); //you must enqueue jquery before enqueueing other scripts
wp_enqueue_script('easing', get_template_directory_uri().'/js/plugin/jquery.easing.js', array('jquery'), '', true);
//keep adding other scripts link like this below

?>

For css files you should do as following

<?php 
wp_enqueue_style('custom-style', get_template_directory_uri().'/css/style.css');
?>

In my examples the file path are not what you will have to use... you will have to use paths relative to your theme's index.php file.

When all of your script files are enqueued then you should delete links from header.php and footer.php files.

For better understanding check https://developer.wordpress.org/themes/basics/including-css-javascript/