Site logo

Archived topic

Building a custom template for blog posts

1 reply · Started by Mori on January 30, 2022

Viewing posts 1–2 of 2

Hi,
I'm using GP in conjunction with Elementor

I want to have a custom template for blog posts so each new blog post will have a few elements and not just the "normal" blog content.
For example - I want to have a first paragraph that is separated from the rest of the content and each time I'm creating a new post I will have an input field for this first paragraph and a separate input field for the rest of the content.
Is this possible?

Hi Mori,

This is certainly possible but will require the use of a Custom field plugin(ex. ACF), GenerateBlocks(for dynamic content), and Hook Element or Block Element, display rule location "Post - All posts"

Here's what you can do:

First, you'll have to create the field for this "first paragraph". You can do this with ACF.

This ACF setup creates a field "First Paragraph" for the posts -
https://share.getcloudapp.com/7Kuq6rrk

With this, your site's posts will have the field to be used as the first paragraph, separate from the rest of the content.

After setting this up, we can add it into the single posts page.

For this one, you can use a Block Element - Hook.
https://docs.generatepress.com/article/block-element-overview/

Within the Block element, place a GenerateBlocks' Headline block and set its dynamic value to "Post meta" and input the ACF's field slug on its Meta field name.

Something like this - https://share.getcloudapp.com/6quEznll

You then set the Block Element's hook location - https://share.getcloudapp.com/bLuxBLnB
(before_content is just an example, you can change it to your preference)

Here's a visual guide on hook locations for posts page - https://docs.generatepress.com/article/hooks-visual-guide/#posts-page

This archived topic is closed to new replies.