简体   繁体   English

Wordpress单个帖子内容没有显示出来

[英]Wordpress Single post content not showing up

I've got a wordpress blog theme which shows the content of all posts on the index fine but when I click into one of the posts the content of the post is blank and I can't seem to figure out why. 我有一个wordpress博客主题,显示索引上的所有帖子的内容很好,但当我点击其中一个帖子时,帖子的内容是空白的,我似乎无法弄清楚为什么。 If I'm correct the single.php controls that page. 如果我是正确的, single.php控制该页面。

http://pastebin.com/afLVxMPb = My single.php http://pastebin.com/afLVxMPb =我的single.php

an example of what I mean would be http://www.ndesign-studio.com/demo/wordpress/blog/how-about-a-blog-post-with-longer-title but on this site the content of the blog post does show up but on mine it doesn't. 我的意思的一个例子是http://www.ndesign-studio.com/demo/wordpress/blog/how-about-a-blog-post-with-longer-title但是在这个网站上的博客内容帖子确实出现了,但在我看来没有。

I think the problem is somewhere here... 我认为问题出在这里...

<div class="entry-content">
      <?php the_content(); ?>
     <?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'your-theme' ) . '&after=</div>') ?>
</div><!-- .entry-content -->

You should add "the loop" somewhere in your single.php file and call setup_postdata($post) or the_post() so you can access the post data inside that loop. 你应该在你的single.php文件中的某处添加“循环”并调用setup_postdata($ post)或the_post(),这样你就可以访问该循环中的post数据。

Read more about the loop here: http://codex.wordpress.org/The_Loop 在这里阅读有关循环的更多信息: http//codex.wordpress.org/The_Loop

For example, your single.php file will look something like this (simplified): 例如,您的single.php文件看起来像这样(简化):

........
<div id="content">
    <?php if(have_posts()) : the_post(); ?>
        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <h1 class="entry-title"><?php the_title(); ?></h1>
            // etc.. all post info

............

<?php endforeach; ?>

Hope that helps! 希望有所帮助! Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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