/ / Błąd łącza URL do pliku CSS - javascript, php, html, css, wordpress

Błąd linku URL do pliku CSS - javascript, php, html, css, wordpress

„Jestem początkującym dla PHP. Dlaczego nie mogę połączyć się z plikiem CSS za pomocą tych kodów? Co jest nie tak z moim kodem? Czy ktoś może mi pomóc?

header.php

<html lang="en">
<head>
<title> </title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="description" content="Bootstrap 3 responsive centered columns">
<meta charset="utf-8" />

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Codrops" />
<script>
var template_dir_js = "<?php echo get_template_directory_uri();?>";
</script>
<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
<script src="<?php echo get_template_directory_uri(); ?>/js/jquery.min.js" type="text/javascript"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/jquery.dropotron.min.js" type="text/javascript"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/jquery.slidertron.min.js" type="text/javascript"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/skel.min.js" type="text/javascript"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/skel-layers.min.js" type="text/javascript"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/init.js" type="text/javascript"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/bootstrap.js" type="text/javascript"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/modernizr.custom.js" type="text/javascript"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/foundation.js" type="text/javascript"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/foundation.min.js" type="text/javascript"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="PSPad editor, www.pspad.com">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://www.google.com/recaptcha/api.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
<link rel="shortcut icon" href="../favicon.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<noscript>
<p><link rel="stylesheet" type="text/css" href="<?php bloginfo("stylesheet_directory"); ?>/css/skel.css" /></p>
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/style.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/style-desktop.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/style-mobile.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/fakeLoader.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/bootstrap-theme.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/gravity-forms-bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/default.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/component.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/foundation-flex.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/foundation.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/foundation.min.css" />
</noscript>
</head>

Przypuszczamlocalhost / wordpress / wp-content / themes / Beyond / css / style.css (poprawny adres URL), ale teraz łączy się z localhost / wordpress / sample-page / css / style.css (zły URL). Jak zmienić link na poprawny adres URL? Wordpress może załadować mój Javascript, ale nie może załadować mojego pliku CSS.

URL do łączenia pliku CSS Katalog plików

Odpowiedzi:

-1 dla odpowiedzi nr 1

Brakuje instrukcji echo. Spróbuj zmienić to:

<link rel="stylesheet" type="text/css" href="<?php bloginfo("template_directory");?>/css/style.css" />

do tego

<link rel="stylesheet" type="text/css" href="<?php echo bloginfo("template_directory");?>/css/style.css" />

czy to pomaga?


0 dla odpowiedzi nr 2
  1. Pobierz wartość katalogu szablonów uri w zmiennej, a następnie użyj go w programie.

     <?php
    $template_dir = get_template_directory_uri();
    ?>
    <link rel="stylesheet" type="text/css" href="<?php echo $template_dir;?>/css/style.css" />