gpt4 book ai didi

php - Wordpress 单篇文章内容未显示

转载 作者:太空宇宙 更新时间:2023-11-04 13:57:18 25 4
gpt4 key购买 nike

我有一个 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 -->

最佳答案

您应该在 single.php 文件的某处添加“循环”并调用 setup_postdata($post) 或 the_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; ?>

希望对您有所帮助!祝你好运。

关于php - Wordpress 单篇文章内容未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4646872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com