Site logo

Archived topic

Create custom stiky subheader

5 replies · Started by Michele on November 21, 2021

Viewing posts 1–6 of 6

Hi everyone, I'm trying to figure out how to create a sticky bar under the header to be displayed only in certain posts.

I would like to avoid using plugins and was wondering if there is any solution using only my premium version of generatepress.

Basically I would like to create a bar under the header with 3/4 columns. The columns will have an image, text and a button inside them which, depending on the post, will always be different.

There's a way?

Thank you so much and good luck,
Michele

Hi Michele,

You can create the content using a block element:
https://docs.generatepress.com/article/block-element-overview/

Choose hookas element type, choose after_header as hook name, choose location depends on your needs (certain posts).

Once it's done, link us to your site, we can have a look to provide some custom CSS to make it sticky :)

Thank you so much Ying! So basically I should create a block for each post, is that correct?

Don't risk make heavy the site too much with, say, 200/300 blocks?

So basically I should create a block for each post, is that correct?

It depends on the content, are they static contents and all different on different post? Or are they pulling custom field values from the each post?

If it's the first case, then you need to create a block element for each post.

If it's the second case, then you would want to use the dynamic feature of the block element (requires GenerateBlocks plugin installed and activated), only 1 block element is needed.

But I would recommend using dynamic feature in your case since you are having 200/300 posts :)

Hi Ying, with your advice I was able to create what I was looking for. A thousand thanks.

I have only one problem left to solve.

I created a sticky bar with 3 columns, the first two are dynamically populated with cover image and post title, in the third column I inserted a button.

However, the link within the button must change based on the post. It will be an affiliate site and each post will have its own "product". How can I avoid creating hundreds of blocks and using only a dynamic one?

I leave you the link to the test page, do not pay attention to the desktop part but just look at the mobile one. At the moment this is a test site just to create the layout for the official site.

https://passionecuccioli.com/carta-prepagata-tinaba/

This archived topic is closed to new replies.