Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.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 Json回调单个post(按id)_Javascript_Jquery_Json_Wordpress - Fatal编程技术网

Javascript Json回调单个post(按id)

Javascript Json回调单个post(按id),javascript,jquery,json,wordpress,Javascript,Jquery,Json,Wordpress,我无法从WordPress获取一个帖子页面并将其显示在移动jQuery页面上。 我需要得到完整的职位名单;点击后,我需要打开一个帖子 这是我获取帖子列表的代码: $.getJSON("http://www.mcaps.at/redesign/api/get_posts/?post_type=reference_member", function posts(data) { var output='<ul data-role="listview" data-inset="true"

我无法从WordPress获取一个帖子页面并将其显示在移动jQuery页面上。 我需要得到完整的职位名单;点击后,我需要打开一个帖子

这是我获取帖子列表的代码:

$.getJSON("http://www.mcaps.at/redesign/api/get_posts/?post_type=reference_member",
function posts(data) {

    var output='<ul data-role="listview" data-inset="true" data-divider-theme="c">';

    $.each(data.posts, function(key,ref){
        output += '<li class="show-more" >';
        output += '<a href="#blog-post" onclick="showPost(' + ref.id + ')">';
        output += '<h3>' + ref.title + '</h3>';
        output += '<img src=" ' + ref.thumbnail + ' " />';
        output += '</a>';
        output += '</li>';
    });

    output+='</ul>';

    $('#referenzen-content').html(output);

});
$.getJSON(“http://www.mcaps.at/redesign/api/get_posts/?post_type=reference_member",
职能职位(数据){
var output='
    ; $.each(data.posts,函数(key,ref){ 输出+='
  • ; 输出+=''; 输出+='
  • '; }); 输出+='
'; $('#referencen content').html(输出); });
如何通过ID获得单个帖子?
谢谢

首先参考API文档,您将发现访问资源的不同方式。我找不到文档,你能发布API文档链接吗?这将有助于你获得好的答案。这里是获取所有帖子的链接:我需要更改此链接并按如下方式调用:函数showPost(id){$.getJSON(“”,函数(数据){var output='';output+=''+data.post.title+'';output+=data.post.content;$('#referencen full').html(output);})首先,API应该有这样的端点,如果你拥有它,那么首先创建它。如果它不存在,那么你唯一能做的就是获取所有的帖子,遍历并找到具有你想要的id的帖子。