specify posts to be pulled by category
-
Hello,
I am using the json api plugin in a wordpress site in correlation with an app being built on phone gap.
we are able to pull the posts using “get_recent_posts” or “get_category_post” but what we need do is be able to pull all the posts that have a particular slug… like slug=news or id=7. My developer and I just can’t seem to figure it out because if we add anything to our code to define what should be pulled it just breaks.
We have tried this: and it only pulls all the posts, not just the ones we want…
<script type=”text/javascript”>
$(document).ready(function(){
$.ajax({
type: “GET”,
url: “http://dc711.net/api/get_recent_posts/”,
dataType: ‘jsonp’,
error: function(){
alert( ‘Unable to load feed, Incorrect path or invalid feed’ );
},
success: function(data){
var html = ‘<div data-role=”collapsible-set”>’ ;
for (var i = 0 ; i < 10 ; i++) {
html += ‘<div data-role=”collapsible”>’;
html += ‘<h4 class=”entry-title”>’ + data.posts[i].title+ ‘</h4>’ ;
html += ‘<div class=”entry-content”>’ + data.posts[i].content+ ‘</div>’ ;
html += ‘</div>’;
}
html += ‘</div>’;
$( “#newslist” ).append(html);
$( “#newslist div[data-role=collapsible-set]” ).collapsibleset();
}});
});
</script><script type=”text/javascript”>
$(document).ready(function(){
$.ajax({
type: “GET”,
url: “http://dc711.net/api/get_category_posts/?category_slug=homepage”,
dataType: ‘jsonp’,
error: function(){
alert( ‘Unable to load feed, Incorrect path or invalid feed’ );
},
success: function(data){
var html = ‘<div data-role=”collapsible-set”>’ ;
for (var i = 0 ; i < 10 ; i++) {
html += ‘<div data-role=”collapsible”>’;
html += ‘<h4 class=”entry-title”>’ + data.posts[i].title+ ‘</h4>’ ;
html += ‘<div class=”entry-content”>’ + data.posts[i].content+ ‘</div>’ ;
html += ‘</div>’;
}
html += ‘</div>’;
$( “#newslist” ).append(html);
$( “#newslist div[data-role=collapsible-set]” ).collapsibleset();
}});
});
</script>and we have tried different variations for the url like:
“http://dc711.net/?json=get_category_posts&slug=news/”,
http://www.site.com/?still nothing. I am not sure what we are missing, please help.
The topic ‘specify posts to be pulled by category’ is closed to new replies.