Forum
Show date/time with postDateTime
Hi, I'm having trouble displaying the date and time of a post using postDateTime.
It seems that something like <perch:blog id="postDateTime" type="text" /> cannot be used on the perch/blog/post.php page. I'm also not able to use it on any of the templates that this page references, example perch/templates/blog/author.html
The only page it is working for me is in perch/templates/blog/post_in_list.html. Is there a reason why I can't use this in other templates.
Can you show us your template and Diagnostics Report please?
Here I can use <perch:blog id="postDateTime" type="text" /> and it outputs the blog post date for each post in the blog index page.
But for the blog post page I want to include the post date in the side bar. The blog/post.php makes up this page using a number of references to files located in the perch/templates/blog folder.
Here for example I have a side bar that pulls in many of these templates. I added <perch:blog id="postDateTime" type="text" /> to the author.html template and the date does not show.
perch/templates/blog/author.html
blog/post.php
An author doesn't have a
postDateTime
field.You can always see what fields are available by using
<perch:showall />
in your template.How can I get postDateTime in my sidebar?
In my post.php file <?php perch_blog_post(perch_get('s')); ?> references the post.html file where the postDateTime is.
How can I use postDateTime in another template?
I also tried using this is my post.php file with a test.html template and that also does not give me the postDateTime.
test.html
Thanks
Yes, you can pass content into a template: https://docs.grabaperch.com/docs/templates/passing-variables-into-templates/
What I was looking for....