If you’re using a for each loop the global $post is going to be the wrapper page you’re on. So a function like get_the_ID() would return the pages ID rather than a specific post.
You’ll have to pass the post id to the shortcode as a parameter for each post. [rt_reading_time post_id=“10”]
Where 10 would need to be the id of the post you’re on within the foreach loop.
The call would work using a standard loop if you’re doing the “the_post()” that sets the $post value.
Hi Jason
Thanks for the quick response. IS it possible to use a variable set for the post ID number being used here? such as $the_id
using other post ID’s do not chnage the output on the page when using like this :
<?php echo do_shortcode(‘[rt_reading_time post_id=”4061″)]’); ?>
The code you shared above has an extra parentheses.
Do you also have a link I could take a look at. Passing the post_id should tell it to calculate the reading time based on that post IDs content.
You can see the code for it here https://github.com/yingles/reading-time-wp/blob/master/rt-reading-time.php#L242
sorry for the late reply
I can send you a link via email if this is ok?
I have since created the read time function manually to apply to specific code loop.