Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Google Feed API时如何获取帖子ID?_Javascript_Php_Json_Wordpress_Rss - Fatal编程技术网

Javascript 使用Google Feed API时如何获取帖子ID?

Javascript 使用Google Feed API时如何获取帖子ID?,javascript,php,json,wordpress,rss,Javascript,Php,Json,Wordpress,Rss,我目前使用两个JS代码从wordpress动态加载帖子: 代码1:JSON API <script src="http://howtodeployit.com/category/daily-devotion/?json=recentstories&callback=listPosts" type="text/javascript"></script> JSON API结果包含每个帖子的ID,但是当由Ajax Google API转换时,RSS提要的结果不包含帖子

我目前使用两个JS代码从wordpress动态加载帖子:

代码1:JSON API

<script src="http://howtodeployit.com/category/daily-devotion/?json=recentstories&callback=listPosts" type="text/javascript"></script>
JSON API结果包含每个帖子的ID,但是当由Ajax Google API转换时,RSS提要的结果不包含帖子ID


我是否需要修改Wordpress RSS代码以包含帖子ID?

我是如何解决这个问题的

步骤1:从我的WordPress永久链接设置中,我选择了自定义结构并添加了/%post\u id%/ 这意味着我的“Link”元素的RSS XML输出结果将采用以下格式:

<myurl>/<postID> (http://howtodeployit.com/111/)
(///)[3]只需将URL除以斜杠的数量,并只取第三位,这是我的帖子所在的位置


我希望这对我这个位置的其他人有用。

在你的
ajax()
调用中缺少一个结束语。…有控制台日志错误吗?@karthikr这是指向控制台的屏幕截图的链接。log result好的,我刚刚注意到,当我查看RSS提要链接并在类别后向下钻取时,我看到一个xxx:howtodeployit.com/?p=442这似乎包含了/?p=之后的每个帖子ID。因此,看起来我必须找到一种方法来排除p=之前的所有内容,并排除以仅提取ID。这对我来说可能是一种先进的方法。有谁能建议我如何让Google API提取附带的xml项:howtodeployit.com/?p=442到JSON?我尝试过google.feeds.Feed.XML_格式和google.feeds.Feed.MIXED_格式,但没有成功
<myurl>/<postID> (http://howtodeployit.com/111/)
var postlink = entry.link;
var id = postlink.split(/\//)[3];