letrunghieu / wordpress-xmlrpc-client

A PHP XML-RPC client for Wordpress websites
MIT License
117 stars 43 forks source link

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

Closed Huskynarr closed 8 years ago

Huskynarr commented 8 years ago

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_perpage.

letrunghieu commented 8 years ago

I test the current version of this library with my Wordpress (4.3) and it works with number and offset parameters. It does not use numberposts and posts_per_page param.

Huskynarr commented 8 years ago

Okay, have it tested again on my Server. With PHP 5 is it no Problem, but with 7 i get this loop.

I get no Errors in the Log. In the Debugging i see, it come from package. :/

letrunghieu commented 8 years ago

Can you switch to the dev-master version of the package and retry with PHP 7.0, I have updated the package in the master branch.

letrunghieu commented 8 years ago

The problem is fixed, you can composer update to get the latest version of this package. Please read the release note of the version 2.5.0 here

Huskynarr commented 8 years ago

:thumbsup: