WordPress.org

Support

Support » How-To and Troubleshooting » Get latest posts with relativ author, tags and categories with only 1 request

Get latest posts with relativ author, tags and categories with only 1 request

  • Hello everyone. I’m developing an application that read data from my WordPress.

    At the moment I’m using directly WordPress functions: http://codex.wordpress.org/Function_Reference/

    I’ll make an example. I want to load latest 15 posts with their relative author information, tags and categories.

    So I have to call

    get_posts that gives me informations about latest 15 posts and than for each of them I have to call get_userdata for author information, get_the_tags for tags and the function to get categories.

    So in total I have 1 query to get 15 posts and 45(15×3) queries to get informations about posts.

    Is there a way to create my own function that gives me with 1 query FULL informations about latest posts?

Viewing 2 replies - 1 through 2 (of 2 total)
  • This is the query I need:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    As you can see I’m pretty new to WordPress. Now With this query I get a record for each tag and category of each post.
    I was wondering if WordPress has some internal function to manipulate this data and get something organized like a Post object with an array of categories and tags. Then I will encode in JSON or XML.

    Can you help me?

    Uhm at the moment I cannot modify my previous post.

    This is the code I was talking about: http://pastebin.com/thYiryr4

    Also, is there a better way to do that? I mean to load latest posts with author, tags and categories with only 1 query?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get latest posts with relativ author, tags and categories with only 1 request’ is closed to new replies.
Skip to toolbar