Поддержка Темы и шаблоны Не могу подключить скрипты к созданной теме

  • Я использую WIN 10, и в качестве сервера Open Server v5.2.2. База данный кодировки utf8_general_ci. Подключаемый скрипт создан в ручную, не был скачанный. Изначально шаблон разрабатывался в index.html, всё стили и скрипты работают, после переноса на WordPress, index.html переименовал в index.php создал slyle.css, вообщем тема подключилась.

    Изначально была проблема со стилями, они не хотят подключаться методом

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

    Я смог подключить стили только так

    
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" />
    

    Стиль заработал, теперь необходимо подключить скрипты, уже второй день ломаю голову, и видео посмотрел, изначально повторял действие по видео курсу, у человека всё заработало, а у меня нет, от до сих пор не могу найти решение.

    Создал папку functions.php поместил туда код, я скопирую всё что там находиться

    
    <?php
    add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
    	function theme_name_scripts() {
    		wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
    		wp_enqueue_script( 'jqueryjs', get_template_directory_uri() . '/libs/jquery/jquery-1.11.2.min.js', array(), '0.1', true );
    		wp_enqueue_script( 'modernizrjs', get_template_directory_uri() . '/libs/modernizr/modernizr.js', array(), '0.1' );
    		wp_enqueue_script( 'bootstrapjs', get_template_directory_uri() . '/libs/bootstrap/js/bootstrap.min.js', array(), '0.1', true );
    		wp_enqueue_script( 'freewalljs', get_template_directory_uri() . '/libs/freewall/freewall.js', array(), '0.1', true );
    		wp_enqueue_script( 'magnificjs', get_template_directory_uri() . '/libs/magnific-popup/jquery.magnific-popup.min.js', array(), '0.1', true );
    		wp_enqueue_script( 'nicescrolljs', get_template_directory_uri() . '/libs/nicescroll/jquery.nicescroll.min.js', array(), '0.1', true );
    		wp_enqueue_script( 'lazyjs', get_template_directory_uri() . '/libs/lazyload/jquery.lazyload.min.js', array(), '0.1', true );
    		wp_enqueue_script( 'commonjs', get_template_directory_uri() . 'common.js', array(), '0.1');
    		}
    ?>
    

    Но браузер выдает такую информацию

    
    <head><link rel="dns-prefetch" href="//s.w.org">
    		<script type="text/javascript">
    			window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/2.2.1\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/2.2.1\/svg\/","svgExt":".svg","source":{"concatemoji":"http:\/\/site-mov\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.7"}};
    			!function(a,b,c){function d(a){var b,c,d,e,f=String.fromCharCode;if(!k||!k.fillText)return!1;switch(k.clearRect(0,0,j.width,j.height),k.textBaseline="top",k.font="600 32px Arial",a){case"flag":return k.fillText(f(55356,56826,55356,56819),0,0),!(j.toDataURL().length<3e3)&&(k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,57331,65039,8205,55356,57096),0,0),b=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,57331,55356,57096),0,0),c=j.toDataURL(),b!==c);case"emoji4":return k.fillText(f(55357,56425,55356,57341,8205,55357,56507),0,0),d=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55357,56425,55356,57341,55357,56507),0,0),e=j.toDataURL(),d!==e}return!1}function e(a){var c=b.createElement("script");c.src=a,c.defer=c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g,h,i,j=b.createElement("canvas"),k=j.getContext&&j.getContext("2d");for(i=Array("flag","emoji4"),c.supports={everything:!0,everythingExceptFlag:!0},h=0;h<i.length;h++)c.supports[i[h]]=d(i[h]),c.supports.everything=c.supports.everything&&c.supports[i[h]],"flag"!==i[h]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[i[h]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings);
    		</script><script src="http://site-mov/wp-includes/js/wp-emoji-release.min.js?ver=4.7" type="text/javascript" defer=""></script>
    		<style type="text/css">
    img.wp-smiley,
    img.emoji {
    	display: inline !important;
    	border: none !important;
    	box-shadow: none !important;
    	height: 1em !important;
    	width: 1em !important;
    	margin: 0 .07em !important;
    	vertical-align: -0.1em !important;
    	background: none !important;
    	padding: 0 !important;
    }
    </style>
    <link rel="stylesheet" id="dashicons-css" href="http://site-mov/wp-includes/css/dashicons.min.css?ver=4.7" type="text/css" media="all">
    <link rel="stylesheet" id="admin-bar-css" href="http://site-mov/wp-includes/css/admin-bar.min.css?ver=4.7" type="text/css" media="all">
    <script type="text/javascript" src="http://site-mov/wp-includes/js/jquery/jquery.js?ver=1.12.4"></script>
    <script type="text/javascript" src="http://site-mov/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1"></script>
    <script type="text/javascript" src="http://site-mov/wp-includes/js/hoverIntent.min.js?ver=1.8.1"></script>
    <script type="text/javascript">
    /* <![CDATA[ */
    var userSettings = {"url":"\/","uid":"1","time":"1483179064","secure":""};
    /* ]]> */
    </script>
    <script type="text/javascript" src="http://site-mov/wp-includes/js/utils.min.js?ver=4.7"></script>
    <script type="text/javascript">
    /* <![CDATA[ */
    var commonL10n = {"warnDelete":"\u0412\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u044d\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b.\n  \u00ab\u041e\u0442\u043c\u0435\u043d\u0430\u00bb \u2014 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u00abOK\u00bb \u2014 \u0443\u0434\u0430\u043b\u0438\u0442\u044c.","dismiss":"\u0421\u043a\u0440\u044b\u0442\u044c \u044d\u0442\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435.","collapseMenu":"\u0421\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043c\u0435\u043d\u044e","expandMenu":"\u0420\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043c\u0435\u043d\u044e"};
    /* ]]> */
    </script>
    <script type="text/javascript" src="http://site-mov/wp-admin/js/common.min.js?ver=4.7"></script>
    <script type="text/javascript" src="http://site-mov/wp-content/themes/themeforr/common.js?ver=4.7"></script>
    <link rel="https://api.w.org/" href="http://site-mov/wp-json/">
    <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://site-mov/xmlrpc.php?rsd">
    <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://site-mov/wp-includes/wlwmanifest.xml"> 
    <meta name="generator" content="WordPress 4.7">
    <style type="text/css" media="print">#wpadminbar { display:none; }</style>
    <style type="text/css" media="screen">
    	html { margin-top: 32px !important; }
    	* html body { margin-top: 32px !important; }
    	@media screen and ( max-width: 782px ) {
    		html { margin-top: 46px !important; }
    		* html body { margin-top: 46px !important; }
    	}
    </style>
    	<meta charset="utf-8">
    
    	<title>Заголовок</title>
    	<meta content="" name="description">
    
    	<link rel="shortcut icon" href="img/favicon/favicon.ico" type="image/x-icon">
    	<link rel="apple-touch-icon" href="img/favicon/apple-touch-icon.png">
    	<link rel="apple-touch-icon" sizes="72x72" href="img/favicon/apple-touch-icon-72x72.png">
    	<link rel="apple-touch-icon" sizes="114x114" href="img/favicon/apple-touch-icon-114x114.png">
    
    	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    	<link rel="stylesheet" href="libs/bootstrap/css/bootstrap.min.css">
    	<link rel="stylesheet" href="libs/magnific-popup/magnific-popup.css">
    
    	<link rel="stylesheet" href="css/fonts.css">
    	<link rel="stylesheet" href="css/main.css">
    	<link rel="stylesheet" href="http://site-mov/wp-content/themes/themeforr/style.css">
    
    </head>
    

    И даже тогда, когда прописываю путь к скрипты на прямую, он всё равно не работает.

    Вообще у меня шаблон состоит из

    Шаблоны
    Подвал
    (footer.php)
    Функции темы
    (functions.php)
    head.php
    Заголовок
    (header.php)
    Основной шаблон
    (index.php)
    Стили
    Таблица стилей
    (style.css)

    Вся эта информация содержится в консоли WP.
    Шапку и подвал подключал с помощью

    
    <?php get_header(); ?> и 
    <?php get_footer(); ?>
    

    а в (header.php) записал вот такую штуку

    
    

    <head><?php wp_head(); ?>
    Здесь Инфо
    </head>
    `
    Всё равно нечего не работает. С наступающим!

Просмотр 1 ответа (всего 1)
  • Получилось? У меня подобное было со стилями, решил копированием файла functions.php из стандартной темы и заменой на своё содержимое. Сам файл был кривой

Просмотр 1 ответа (всего 1)
  • Тема «Не могу подключить скрипты к созданной теме» закрыта для новых ответов.