Forum

Thread tagged as: Question, Blog

Blog Categories - updating for previous blog entry

I'm using perch_blog_categories(); to return a list of the blog categories and numbers.

When I add a new blog item, it doesn't update the category number for the category type I have just added, it updates it for the previous blog I added - so I am always one behind.

Does anyone know what is wrong?

Its a standard install of blog. Latest versions of Perch and Blog.

cow shed

cow shed 0 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you in development mode or production mode? In production those counts are cached so they don't update immediately.

I'm in production mode. I thought it might be a caching problem, but its still showing 1 less this morning. I can bump the number up each time I add a new blog, but it always refreshes the category for the blog entry I entered previously rather than the category for the blog entry I have just added. So its always one less overall than it should be ...

https://www.cannizaropark.com/cannizaro-pages/index.php

Ok so this is getting stranger.

So in summary, if I add n blog posts, the category_link categories show (n-1) blogs and the post_category_link categories show 1 blog.

I deleted all my blog entries so I could start again. The first two added fine and updated the categories as expected. The third one has not.

I have edited category_link (Categories) and post_category_link (Categories...) so I can see which is being used and it seems it is using category_link for the first and second blog items and post_category_link for the third one.

What I see on my post : (https://www.cannizaropark.com/blog/post.php?s=2018-10-12-coast-redwood)

Categories - xxxx (1)

  • yyyy (1)

Categories... - zzzz (1)

Where category_link.html has :

<h3>Categories</h3>

and post_category_link.html has

<h3>Categories...</h3>

I have now added some more and it is always showing one less than it should.

Drew McLellan

Drew McLellan 2638 points
Perch Support

In the examples you're showing, the category counts look correct from what I can understand of your site.

No its not correct. I have 6 posts and 5 category counts.

Every device I have tried it on show there are 6 blog post entries and only 5 (1+3+1) show in the Categories on the blog/index.php page or on the blog/post.php pages.

The category for the last blog post to be added is still missing.

I have double checked on 3 devices that have not had the website on them and also cleared the cache on my main machine (many times!) incase it was a caching problem. As before I can get the category to show by adding a new post, but then the category for the new post wont show...

Drew McLellan

Drew McLellan 2638 points
Perch Support

The cache is server side, not client side.

If I go here: https://www.cannizaropark.com/blog/post.php?s=2018-10-12-coast-redwood

Under Categories I see Pond (3)

If I click on Pond (3) I get a list of 3 results.

How is that wrong?

The 6th blog item I added was Oriental Plane which has a category of Main Lawn Right. That category isn’t showing.

Drew McLellan

Drew McLellan 2638 points
Perch Support

So the issue is that you're not seeing a category that you think you should be, and not to do with the counts being displayed?

Well both really. If I add another Main Lawn Right item it will bump up that category count to 1 when it should be 2. It just so happens here that there is only 1 in the category so it shows the count as 0 (and so doesn’t show at all).