Forum
Blog Post on Home Page Breaks When postStatus = Draft
Hi all
Using Runway and Perch Blog, I am displaying the latest blog post on the home page using the following...
perch_blog_custom(array(
'filter' => 'postDateTime',
'match' => 'gte',
'value' => date('Y-m-d'),
'sort' => 'postDateTime',
'sort-order' => 'DESC',
'count' => 1,
'template' => 'blog/home_page.html'
));
...which in itself all works absoultely fine.
The problem occurs when the latest blog post status is set to draft. When this occurs the template breaks.
How do I display not only the latest blog post but the latest post that's also got a post status of Published only, please?
Many thanks
What do you mean by breaks?
The template blog/home_page.html doesn't display at all if the latest blog post is set to draft. If you view source it's not there.
What does debug output?
This is what the debug looks like when the latest blog is set to Published...
and this when the latest blog post is set to draft...
Neither of those match the code you're showing me above.
Which bit of the debug do you need?
The above was taken from the frontend home page & I just copied the part which referred to the template in question.
It would save a lot of back and forth if you posted all of it.
Here you go Drew. This is what I get on the home page when the latest blog post status is set to Draft...
Your filter is targeting posts with a date greater than the current time, and the default filtering targets posts in the past, so you've only got a very narrow window to match any posts.