1

I'm using Kirby CMS and I need to find out how many posts I have.

My posts are gotten with

$posts = $pages->find('posts')->children();

which echos an object with 10 items (links to the posts).

It is not an array so using count() returns 1.

How can I count the items in this object like I would with an array?

8
  • 3
    what does var_dump( $posts ); show? Commented Jul 24, 2013 at 0:55
  • maybe you can conver it to an array Commented Jul 24, 2013 at 0:55
  • is it like a string? is there a delimiter between each posts? Commented Jul 24, 2013 at 0:57
  • @marabutt var_dump shows a whole massive bunch of stuff, which I guess is all the data about all the posts. Commented Jul 24, 2013 at 1:10
  • @sanjaypoyzer can you add it to your post? Commented Jul 24, 2013 at 1:12

1 Answer 1

2

I have no experience with this library. But try this, it might work:

$count = $pages->find('posts')->children()->count();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.