Skip to content

Get always the Last 10 Posts (Published & Draft) #25

@Huskynarr

Description

@Huskynarr

I don't know whether it is because of my Code, The Client or Wordpress.
But i get always the last 10 posts wherever which limit is set.
And in this posts are the draft and published.

My Code:

function getLastNews($number = 1, $offset = 1)
{
  $endpoint = "https://sub.domain.tld/xmlrpc.php";

  $wpClient = new \HieuLe\WordpressXmlrpcClient\WordpressClient();

  $wpClient->setCredentials($endpoint, 'OneOfMillionUser', 'myverystrongmysterysecretkey');

  $return = $wpClient->getPosts(array('post_type' => 'post', 'post_status' => 'published', 'offset' => $offset, 'number' => $number, 'orderby' => 'date', 'order' => 'DESC'));

  return $return;
}

I think this is correct. It have works a long time(PHP 5.6, i work an the develop Machine with PHP 7). :/
Instead number I have numberposts and tried posts_per_page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions