Ski*_*zit 2 html css php wordpress wordpress-theming
我有一个wordpress博客主题,显示索引上的所有帖子的内容很好,但当我点击其中一个帖子时,帖子的内容是空白的,我似乎无法弄清楚为什么.如果我正确的single.php页面控件.
http://pastebin.com/afLVxMPb =我的single.php
我的意思的一个例子是http://www.ndesign-studio.com/demo/wordpress/blog/how-about-a-blog-post-with-longer-title但是在这个网站上的博客内容帖子确实出现了,但在我看来没有.
我认为问题出在这里...
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'your-theme' ) . '&after=</div>') ?>
</div><!-- .entry-content -->
Run Code Online (Sandbox Code Playgroud)
你应该在你的single.php文件中的某处添加"循环"并调用setup_postdata($ post)或the_post(),这样你就可以访问该循环中的post数据.
在这里阅读有关循环的更多信息:http://codex.wordpress.org/The_Loop
例如,您的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; ?>
Run Code Online (Sandbox Code Playgroud)
希望有所帮助!祝好运.
| 归档时间: |
|
| 查看次数: |
11556 次 |
| 最近记录: |