简体   繁体   中英

Wordpress custom theme only working on home page

I created a website and added wordpress to it for others to easily manage the content. The theme works perfectly on the page designated for the homepage and not for every other page. Pages in question appear as though the stylesheet is missing.

I'm currently working from my localhost.

This is my header.php file:

<!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>

And this is my page.php file (it's the same as the index.php file):

<?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(); ?>

Thank you

In your header.php, use this:

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

instead of this:

<link href="wp-content/themes/theme_name/css/style.css" rel="stylesheet" type="text/css" media="all">

...do the same for the other stylesheet too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM