【问题标题】:Wordpress use index.php instead of single.php to show postWordpress 使用 index.php 而不是 single.php 来显示帖子
【发布时间】:2013-01-07 16:48:56
【问题描述】:

我的 Wordpress 网站没有使用 single.php 在网站上显示帖子。每次我打开一个帖子时,它都会在 index.php 中打开它。

我的 single.php 是这样的

<?php get_header(); ?>
  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <? echo the_content(); ?>
  <? endwhile; 
  endif; ?>
<? get_footer();
?> 

我该如何解决这个问题?

【问题讨论】:

标签: php wordpress wordpress-theming


【解决方案1】:

我遇到了同样的问题,在单击单后链接后,single-CUSTOM-TYPE.php 和 single.php 都没有呈现......只有 index.php 而不是正确的文件......

帮助我的是在“设置”->“永久链接”中简单更改回标准永久链接并恢复为“帖子名称”(Beitragsname)......

...也许这对其他人也有帮助... 打招呼

【讨论】:

  • 只需转到此设置页面并再次保存就足够了。
【解决方案2】:

如果 LOOP 设置不正确,请确保 index.php 和 single.php 包含 LOOP。

循环通常看起来像这样,但会根据设置要求进行更改。

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

Wordpress Codex 网站非常棒,可以回答大多数问题,请查看 http://codex.wordpress.org/The_Loop

如果您在 stacks 姊妹网站 Wordpress Stackexchange 上发帖,还有更多问题和讨论,例如这个更理想。我希望这个问题会被删除或移至https://wordpress.stackexchange.com/

【讨论】:

  • 代码中已经准备好了。我在我的问题中添加了代码 sn-p。
【解决方案3】:

你应该检查你的 loop.php 或 loop-single.php 天气,它是从这些文件中路由的,还是不是它将从数据库中获取数据的页面

【讨论】:

    猜你喜欢
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多