{{reading_time}} not working in partials

I am editing the byline-single.bhs file of Casper theme.

I have added this code in it to render estimated reading time for the post but it is not work, there is no output.

<span> {{#post}} {{reading_time}} {{/post}} </span>
  • What’s your URL? Localhost
  • What version of Ghost are you using? 2.13.2

I’m hoping someone here can help me with this. Thanks image

Can you check that you’re not already in the post context? Without looking at the rest of the file it’s hard to tell, but from what I can see, it looks like you might be trying to go into the post.post context, which doesn’t exist

1 Like

Vikas, thank you for the response.

post.hbs - https://pastebin.com/raw/6WwgtjbZ

byline-single.hbs - https://pastebin.com/raw/xdjYXRvd

Because you’re in the primary_author context, the reading time helper won’t work - what you’re effectively saying is “Give me the post.primary_author.post and generate the reading_time from that”.

I’m not sure if this is the only way, but one fix is to close the primary_author context right before you run the helper. You also might be able to get it to work by doing {{../reading_time}} but I’m not entirely sure.

1 Like

Thanks, it worked!

image

https://pastebin.com/raw/56v442ad

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.