Jump to content

numPosts in Blog Problem


MateThemes
 Share

Recommended Posts

Hello everyone!

I use ryans blog site profile to build my template around it. I use my mamp pro setup with php 7, mysql 5 and apache server. On my local setup the following code works fine:

<?php foreach(page()->children as $category): ?>
	<a class='uk-link-reset' href='<?=$category->url?>'>
		<div class='uk-card uk-card-default uk-card-hover uk-card-body'>
			<h3 class='uk-card-title uk-margin-remove'><?=$category->title?></h3>
			<span class='uk-text-muted'><?=$category->numPosts(true)?></span>
		</div>
	</a>
<?php endforeach; ?>

It is the same code as ryan used it, only my css classes. On my live server with the same setup as mamp pro i got following error:

sceenshot1.thumb.png.74e56226dd4357c1ba4b6a18ac2958c5.png

Does anyone have the same error in this context?

Thank you very much for your help!

Link to comment
Share on other sites

Possible reasons...

1. Your /site/ready.php is missing this code: https://github.com/ryancramerdesign/regular/blob/master/site-regular/ready.php

2. The child pages you are looping over do not (all) use a template named "category". The hook code linked to above attaches a numPosts() method only to pages using the template "category".

Link to comment
Share on other sites

12 hours ago, Robin S said:

Possible reasons...

1. Your /site/ready.php is missing this code: https://github.com/ryancramerdesign/regular/blob/master/site-regular/ready.php

2. The child pages you are looping over do not (all) use a template named "category". The hook code linked to above attaches a numPosts() method only to pages using the template "category".

Hello!

Thank you for your answer. I checked both reasons but they are not the reason for the error.

The crazy think is that it works great on my local mamp installation?!

Link to comment
Share on other sites

10 hours ago, dragan said:

Are you really sure it's the same setup? Are the relevant pages published and un-hidden?

Yes!

By the way I exported the site with the exporter tool. It is the same as on the mamp installation.

I will check everything again. Maybe I didn't see something!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...