Title: WordPress &#8220;get_posts()&#8221; function not working
Last modified: July 9, 2021

---

# WordPress “get_posts()” function not working

 *  [killian1726](https://wordpress.org/support/users/killian1726/)
 * (@killian1726)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-get_posts-function-not-working/)
 * Hello,
 * After about an hour searching on the internet to solutions to my problem, I’ve
   finally decided to ask for help here, hoping that someone would be able to help
   me with my problem. 🙂
 * It’s the first time I’m using the “get_posts()” function because I’m trying to
   get informations about the user’s orders from the database.
 * After passing the arguments I wanted to the function, it returned an empty array.
   
   So what I’ve decided to do is to get rid of all the arguments and just call the
   method with an empty array to see if the problem came from the arguments I was
   passing to the function.
 * But when calling the function with no arguments ( $request = get_posts( array());)
   and dumping the result, I still had an empty array… with no message of error :\
 * Does somebody knows why that might happen ?
 * I am trying to call the function from a php file in a plugin (Tutor), so I really
   don’t know why it doesn’t want to return anything.
 * Also, I am using version 5.7.2 of WordPress, which is currently the last one.
 * Any piece of informations would be really appreciated ! Thanks in advance 🙂
    -  This topic was modified 4 years, 9 months ago by [killian1726](https://wordpress.org/support/users/killian1726/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fwordpress-get_posts-function-not-working%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-get_posts-function-not-working/#post-14645030)
 * Reference: [https://developer.wordpress.org/reference/functions/get_posts/](https://developer.wordpress.org/reference/functions/get_posts/)
   
   The default post type is ‘post’. Do you have an “orders” post type? If not, then
   that’s why nothing was returned. But calling with no parameters would use the
   defaults, so it indicates you have no posts or your code was not executed.
 * If you have a plugin to create the orders, you can ask at the plugin’s support
   forum for how to retrieve them. They might be in a separate table.
 *  Thread Starter [killian1726](https://wordpress.org/support/users/killian1726/)
 * (@killian1726)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-get_posts-function-not-working/#post-14646839)
 * Ooh that’s it, I’ve added an article and now the function returns something !
 * Thanks a lot for you help, I can now move on with my work.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WordPress “get_posts()” function not working’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [killian1726](https://wordpress.org/support/users/killian1726/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-get_posts-function-not-working/#post-14646839)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
