【发布时间】:2015-08-26 19:40:47
【问题描述】:
所以,我正在处理一个自定义 Wordpress 主题并遇到了一个非常奇怪的问题,但我找不到解决方案。现在,我有两个页面设置了虚拟内容,一个设置为静态首页。但是,这两个页面的内容都被拉到了主页上。
这里是实时网站的链接。 wintonsmotionpictures.com
我一直在将事情简化为基础,试图找出问题所在。这是我的 page.php 文件的内容。
<?php
// Filename: page.php
get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="container">
<?php the_content();
endwhile; endif;
?>
</div>
<?php get_footer(); ?>
这是被吐出到 Firebug 中的 HTML 内容。
<main>
<section class="wrapper">
<div class="content-wrap">
<div class="container">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu est condimentum, dictum nibh vitae, maximus arcu.</p>
<div class="container">
<p>Fusce mollis justo vitae porta porta. Proin congue fringilla quam et vehicula. Mauris commodo arcu sit amet neque elementum vestibulum.</p>
</div>
</div>
</div>
</section>
</main>
这也是我的 header.php 文件。同样,整个主题都被相当精简了。
<?php
/*
Filename: header.php
Author: Jesse Winton
*/
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php
/*
* Print the <title> tag based on what is being viewed.
*/
wp_title( '|', true, 'right' );
?></title>
<!-- stylesheets -->
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,800,700|Merriweather:400,700" rel="stylesheet" type="text/css">
<!-- / stylesheets -->
<!-- scripts -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="<?php bloginfo( 'template_directory' ); ?>/js/modernizr.js" type="text/javascript"></script>
<!-- / scripts -->
<!-- meta tags -->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="author" content="Jesse Winton Design"/>
<meta name="robots" content="Index, Follow"/>
<meta name="viewport" content="user-scalable=yes, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<!-- / meta tags -->
<?php wp_head(); ?>
</head>
<body>
<?php query_posts(array('post_type'=>'page', 'orderby' => 'menu_order', 'order' => 'ASC')); ?>
<?php if(have_posts()): while(have_posts()): the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; endif; ?>
<main>
<section class="wrapper">
<div class="content-wrap">
我一辈子都找不到这里的问题。任何想法将不胜感激。
谢谢,
杰西
【问题讨论】:
-
我不太确定我是否关注了你,但你在
page.php中有一个循环,它会遍历你的所有帖子,并为每个帖子调用the_content。为什么你会期望它只是占据首页? -
@andrewsi 看到我的编辑,包括一个链接。