Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
If statement based on subdomain
Participant
Jul 10, 2019 1:17 PM
I'm trying to create a recent posts section using this code. This will display at the bottom of blog posts. I have 4 blogs in Hubspot on different subdomains. Is it possible to write an if statement that will print the recent posts based on which blog it's on? If that isn't possible, is there some other way of doing this without creating 4 separate blog post templates?
I was thinking something like:
{% if blogid='subdomain1' %} {% set posts = blog_recent_posts('SUBDOMAIN1', 3) %} {% for post in posts %} <h3><a href="{{ post.absolute_url }}">{{ post.name }}</a></h3> <img src="{{ post.featured_image }}" alt="{{ post.name }}"> {% endfor %} {% elif blogid='subdomain2' %} {% set posts = blog_recent_posts('SUBDOMAIN2', 3) %} {% for post in posts %} <h3><a href="{{ post.absolute_url }}">{{ post.name }}</a></h3> <img src="{{ post.featured_image }}" alt="{{ post.name }}"> {% endfor %} and so on...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content