Kavita
Kavita

Reputation: 245

get posts function not working wordpress

I have developed a wordpress website in which I have used get_posts() function .Few days ago I found the wordpress was updated on my server. Since then my get_posts() function is not working. I have used get_posts() without any argument still it is not working. I have used some other functions like get_users() which are working fine. Right now I have Version 4.1.1

    $args = array(
            'posts_per_page' => 10,
            'offset' => 0,
            'category_name' => 'press',
            'orderby' => 'post_date',
            'order' => 'DESC',
            'post_type' => 'post',             
            'post_status' => 'publish',
           'suppress_filters' => true
    );

        $posts_array = get_posts();

Upvotes: 1

Views: 209

Answers (1)

Andrew E
Andrew E

Reputation: 184

You need to pass your $args to get_posts(). There may be other issues, but at least do that.

$posts_array = get_posts($args);

Upvotes: 1

Related Questions