- This topic has 5 replies, 2 voices, and was last updated 4 years, 4 months ago by
Ying.
-
AuthorPosts
-
November 21, 2021 at 4:37 pm #2013839
Michele
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,
MicheleNovember 21, 2021 at 4:41 pm #2013841Ying
StaffCustomer SupportHi Michele,
You can create the content using a block element:
https://docs.generatepress.com/article/block-element-overview/Choose
hookas element type, chooseafter_headeras hook name, chooselocationdepends 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 🙂
November 21, 2021 at 4:44 pm #2013842Michele
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?
November 21, 2021 at 4:52 pm #2013847Ying
StaffCustomer SupportSo 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 🙂
November 22, 2021 at 8:35 am #2014914Michele
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.
November 22, 2021 at 11:10 am #2015637Ying
StaffCustomer SupportYou can use custom fields of WP in the post editor: https://wordpress.org/support/article/custom-fields/
Create a custom field to store the product link, then use the button to pull the link from the custom field.
Here’s a demo video which uses custom field content, you can start to watch from 0:57 to see the custom field in the post editor: https://youtu.be/H6wHd83DfDI?t=57
Let me know if this helps 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.