最近,有人为我定制了一个WP博客。这个人没有做很好的工作,所以我决定自己做。我定制了我自己的博客页面,这一切都能工作,除了当我点击帖子时,我得到了一个“找不到错误”页面。我翻阅了一些人写的旧博客,我不知道那个人把我的帖子链接到了哪里。我唯一的线索是在<?php the_content(); ?>之后的代码:
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>当我定制我自己的页面时,我忽略了这段代码。现在,当我点击“邮报”时,我得到了一个“找不到错误”,这是我的博客页面:
<?php
/*
Template Name: Blog
*/
?>
<?php get_header(); ?>
<br/>
<br/>
<section id="content">
<div class="main">
<div class="inner">
<h3 class="h3 bg-3">Web Design inspiration, all resources you could need !</h3>
</div>
</div>
<?php if (have_posts()) : ?>
<?php query_posts('posts_per_page=3'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="main">
<div class="cycle">
<div id="slider3" class="pics">
<div class="box">
<article>
<figure class="box-img img-indent"><a class="lightbox-image box-image" data-gal="prettyPhoto" href="<?php echo catch_that_image() ?>"><img src="<?php echo catch_that_image() ?>" alt="" /></a></figure>
<div class="inner"><a class="link-1" href="<?php the_permalink() ?>" title="Go to <?php the_title(); ?>"><?php the_title(); ?></a><br>
<div class="txt-3"><strong>Posted on:</strong> <span><?php the_time('m/d/y') ?></span></div>
<p class="p3"><?php the_content() ?>
</p>
</div>
<div class="clear"></div>
<?php endwhile; ?>
</article>
</div>
</div>
</div>
<br/>
<br/>
<div class="navigate2">
<div id="nav"></div>
<?php next_posts_link('<span id="next_slide2"> </span>') ?></div>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php endif; ?>
</section>
<?php get_footer(); ?>提前感谢!(P.S.我在本地主机工作,所以没有你可以访问的网页。)
发布于 2012-09-02 19:14:13
您在问题中包含的文件是一个自定义的页面模板,WordPress绝不会使用它来呈现博客帖子的单一帖子视图。
如果您没有single.php,那么模板层次结构将回落到index.php为博客文章呈现单一的post视图。
以下是您的评论:
对不起。我需要我的帖子链接到一个单独的页面。我不知道怎么做。我以为WP会自动将我的帖子链接到一个名为single.php的页面。我想知道怎么做。
请阅读一下这个模板层次结构法典分录,它为您解释了一切。我重复上面的答案:如果主题没有single.php**,那么[模板层次结构将返回到** index.php](http://codex.wordpress.org/Template_Hierarchy#Single_Post_display)来呈现博客文章的单一帖子视图。
这是WordPress用来呈现博客帖子的单一帖子视图的唯一两个可能的模板文件。
关于这一评论:
我不知道如何使我的Permalinks链接到一个single.php页面,我不希望它们链接回index.php页面。
我认为您没有完全理解WordPress如何使用它的模板文件。index.php文件不是“页面”,而是用于输出给定查询的模板。您的主题可以由index.php以外的其他模板文件组成,并且站点将呈现得非常好,并且按照预期/预期。WordPress只需使用模板来定义用于在给定查询中呈现数据的标记。
如果该查询是博客帖子索引,那么WordPress将使用它来呈现博客帖子索引的所有帖子。如果该查询是存档索引,那么WordPress将使用它来呈现指定存档中的所有帖子。如果该查询是单个博客文章,那么WordPress将使用该模板来呈现单个博客帖子。
那么:你不希望你的主题回到index.php模板文件来呈现单个博客文章有什么特别的原因吗?
https://wordpress.stackexchange.com/questions/63904
复制相似问题