简体   繁体   English

在静态html页面上显示最近的wordpress帖子

[英]show recent wordpress post on static html page

I have a site that is done in HTML/PHP, mostly using static .html files. 我有一个使用HTML / PHP完成的网站,大部分使用静态.html文件。

I added a blog, and would like to grab the posts from it to display in the sidebar of the homepage. 我添加了一个博客,并希望从中获取帖子以显示在主页的边栏中。

I've followed this guide to do so. 我已按照本指南进行操作。

The problem is its not working, and I'm not 100% certain if the correct wordpress file is being pointed to. 问题是它无法正常工作,我不能100%确定是否指向了正确的wordpress文件。

The blog is kept in a directory called wordpress. 该博客保存在一个名为wordpress的目录中。 So my statement looks like this: require('wordpress/wp-blog-header.php'); 所以我的陈述看起来像这样: require('wordpress/wp-blog-header.php');

Is there something wrong with this? 这有什么问题吗? Is there a way to check using chrome if the file has been found / loaded? 有没有一种方法可以使用chrome检查文件是否已找到/加载?

Thanks 谢谢

If you intend on sticking solely to static HTML pages, the tutorial you mentioned will not help you. 如果您打算仅坚持使用静态HTML页面,那么您提到的教程将无济于事。 Your only option here is to fetch your blog posts from an RSS feed or a JSON feed using JavaScript. 您唯一的选择是使用JavaScript从RSS feed或JSON feed中获取博客文章。 I would go for the latter since it's easier to deal with (especially if you utilise jQuery). 我会选择后者,因为它更易于处理(特别是如果您使用jQuery)。

Here's a few things for you to check out or read up on: 以下是您可以查看或阅读的一些内容:

http://wordpress.org/extend/plugins/json-api/ http://wordpress.org/extend/plugins/json-api/

http://api.jquery.com/jQuery.getJSON/ http://api.jquery.com/jQuery.getJSON/

Parse RSS with jQuery 用jQuery解析RSS

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

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