Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress自定义主题仅适用于主页_Php_Wordpress_Wordpress Theming - Fatal编程技术网

Php Wordpress自定义主题仅适用于主页

Php Wordpress自定义主题仅适用于主页,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,我创建了一个网站,并将wordpress添加到其中,以便其他人轻松管理内容。 该主题在为主页指定的页面上非常有效,而不是在其他页面上。出现问题的页面似乎缺少样式表 我目前正在本地主机上工作 这是我的header.php文件: <!doctype html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo('charset');?>

我创建了一个网站,并将wordpress添加到其中,以便其他人轻松管理内容。 该主题在为主页指定的页面上非常有效,而不是在其他页面上。出现问题的页面似乎缺少样式表

我目前正在本地主机上工作

这是我的header.php文件:

<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset');?>">
<title><?php
global $page, $paged;
wp_title( '|', true, 'right' );
bloginfo( 'name' );
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
    echo " | $site_description";
if ( $paged >= 2 || $page >= 2 )
    echo ' | ' . sprintf( __( 'Page %s' ), max( $paged, $page ) );
?></title>

<link href="wp-content/themes/theme_name/css/carousel.css" rel="stylesheet"     type="text/css" media="all"/>
<link href="wp-content/themes/theme_name/css/style.css" rel="stylesheet"     type="text/css" media="all">
<?php wp_head(); ?>
</head>

<body>
<div id="wrap">
<div class="header">
<nav>
    <div class="login">
    <a href="login.html"></a><span class="login-icon"><p><a href="login.html">Login / Register</a></p>
    </span>
  </div>

    <div class="logo">
    <img src="wp-content/themes/theme_name/img/logo.png" alt=""/> 
    </div>

    <div class="navbar">
        <?php
        wp_nav_menu(array(
          'theme-location' => 'primary-menu',
          'menu_class' => 'nav',
          'fallback_cb' => 'wp_page_menu'
          ));
        ?>
    </div>
   </nav>
<?php
get_header(); ?>

<div id="primary" class="content-area">
    <div id="content" class="site-content" role="main">

        <?php /* The loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>

            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <header class="entry-header">
                    <?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
                    <div class="entry-thumbnail">
                        <?php the_post_thumbnail(); ?>
                    </div>
                    <?php endif; ?>

                </header><!-- .entry-header -->

                <div class="entry-content">
                    <?php the_content(); ?>

        <?php endwhile; ?>

    </div><!-- #content -->
</div><!-- #primary -->

<?php get_footer(); ?>


在header.php中,使用以下命令:

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

如果使用()(例如
)而不是硬编码到
style.css的路径,会发生什么?我怀疑是您使用的相对路径导致了从根(相对路径正确的地方)以外的任何地方加载问题。非常感谢!我硬编码,因为我没有任何想法,为什么这不起作用?但对链接图片不起作用:-(这很好用,很好。也适用于图片。WP的原生主题将此功能用于样式表和图片。如果答案有帮助,请向上投票。
<link href="wp-content/themes/theme_name/css/style.css" rel="stylesheet" type="text/css" media="all">