【问题标题】:How do I display one (featured) post from Wordpress on my static html website?如何在我的静态 html 网站上显示来自 Wordpress 的一篇(精选)帖子?
【发布时间】:2013-01-08 23:28:00
【问题描述】:

我们的网站 (http://www.litepanels.com/news/) 上有一个 Wordpress 新闻博客,它与静态 html 网站的其余部分是分开的。我只想获取最新的故事(精选帖子)并将其显示在我们的主页上。博客和我们的网站在同一台服务器上。我发现我可以抓取这样的帖子标题:

<?php
require('../news/wp-blog-header.php');
 ?>
<?php query_posts('showposts=3'); ?>
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php       the_title(); ?>"><?php the_title(); ?></a><br />
<?php endwhile;?>

但我不太了解 PHP,如何仅获取精选帖子(如您在上面的链接中看到的标题、图像和文本)

我在这里测试它:http://www.litepanels.com/newwebsite/blog_test2.php

【问题讨论】:

标签: php html wordpress


【解决方案1】:

如果这对您有用,则意味着您拥有所需的一切,但可以通过某种方式显示您的信息。为此,Wordpress 提供了一些可以在 while 循环中使用的模板标签。 the_content 是您需要的。 Others can be found in the Codex.

【讨论】:

  • 感谢您查看我上面的测试链接,我开始明白了。我可以修复我所做的快速 CSS,但我不明白如何使用 read more> 类型的链接切断其余内容?
  • 如果您的内容中有 应该会自动完成。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-23
  • 1970-01-01
  • 2012-08-30
  • 2021-06-14
  • 2015-01-03
  • 1970-01-01
相关资源
最近更新 更多