Skip to main content

How do I check for the parent of the current blog post?

I have a site that has two different blogs: Stories and News. On the single posts page, I want to be able to check if the parent of the post is the News page so I can display some additional content. I thought one of the conditionals below might work, but having no luck. Any help?

{% if page.parent.slug == 'news' %}

{% if post.parent.slug == 'news' %}

Official response from

Blog posts are referred to as "post" on the Blog page-type, but on the individual blog posts they're a "page." Therefore, the code you're looking for is:

{% if page.parent.slug == 'news' %}

conditional code goes here

{% else %}

alternative code goes here


{% endif %}

Share this post

Showing 6 reactions

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.