- This topic has 9 replies, 4 voices, and was last updated 3 years, 4 months ago by
Fernando.
-
AuthorPosts
-
November 29, 2022 at 9:33 am #2441487
gpstart
I have a custom post type with custom fields attached to it.
I want to create a custom template and add those custom fields to it.
Is there documentation for this?
If not, can someone please outline the steps to carry this out?
I am using Metabox for the custom fields and custom post type.
Thanks.
November 29, 2022 at 10:09 am #2441549David
StaffCustomer SupportHi there,
to begin with you need to create your single template and content template.
The simplest option is to follow the steps provided here:
https://docs.generatepress.com/article/setting-up-a-simple-custom-post-type/
However if you want to build the template using a Block Element, then let me know as Step 3 will need to be different. Let me know.
November 29, 2022 at 11:50 am #2441713gpstart
Just want to check, because I mentioned I created my custom post type using Metabox, but, I edited my post. Not sure if you responded before I edited it or after.
So, creating the post type using Metabox is of no use? I still need to follow the above instructions?
November 29, 2022 at 4:28 pm #2441979Ying
StaffCustomer SupportIf the CPT has already been created using a plugin, then you don’t need to create it again.
You can start to create the template using
block element - content template:
https://docs.generatepress.com/article/block-element-content-template/Make sure GenerateBlocks plugin is installed, so you can use its dynamic data feature to pull the custom field’s value:
https://docs.generateblocks.com/article/headline-overview/#dynamic-dataNovember 30, 2022 at 1:29 pm #2443536gpstart
Thanks. But, I still can’t find how to insert a custom field.
I tried using a Headline and it offers me a Dynamic Text Type.
I tried using a Button and it offers me a Dynamic Text Type and Dynamic Link Type.
In the options above, I don’t see any option for a custom field.
See image:
Based on the second link you provided, I saw in the sidebar an option to enable Dynamic Data. I did that and then I could select the Data Source of my post type (called Brand). That looks good. But, then I have to select a specific Brand from my custom post type. I don’t want to have to select a specific Brand. I want this to apply to all Brand posts.
Is this the way it’s supposed to work?
November 30, 2022 at 5:32 pm #2443755Fernando Customer Support
Hello there,
I believe you have the wrong Dynamic setting which is why it’s not working as expected. If you’re trying to show a post meta field through a Headline Block specific to all “Brand” Posts, try setting the Data Source to Current Post, the Content Source to Post Meta, and the Post Meta Field to the field name set in Metabox.
Example: https://share.getcloudapp.com/04uyrYzk
This setup should grab the specific Post Meta dynamically on all brands you have if I’m understanding your structure correctly.
Let us know how it goes.
November 30, 2022 at 6:45 pm #2443788gpstart
Thank you Fernando, that worked!
However, after I implemented it, it replaced the content of what was originally in the specific brand post.
My intention was to add these custom fields, created for my Brand posts, to the end of the content.
I noticed that there is a “Post Content” block. And I included that before including the custom fields. And that seemed to fix it.
It looks right. Just want to check if that would that be the right way to implement this: That is to add custom fields to the end of the Brand post.
Not sure if there is a “better” way of doing it. For example, the original way I did it, it replaced my content. Is there a way for it to get added to the bottom of each Brand post as opposed to having to use the “Post Content” block.
November 30, 2022 at 7:08 pm #2443814Fernando Customer Support
I see. Glad that worked.
Yes, using a Content Template with a Post Content Block is one way to do it.
Another way, as opposed to using a Content Template, is to just use a Block Element – Hook. Hook it to
before_footeror somewhere you prefer. See here for some hooks you can try: https://docs.generatepress.com/article/hooks-visual-guide/With this, you wouldn’t need a “Post Content” Block. You’re just basically injecting the custom fields at the bottom of each “brand”.
Reference: https://docs.generatepress.com/article/block-element-hook/
December 1, 2022 at 4:55 am #2444289gpstart
Thank you very much. I’m so glad I found GeneratePress. I just started using it and it’s pretty amazing, including the support.
December 1, 2022 at 5:10 pm #2445859Fernando Customer Support
You’re welcome! We’re glad you’re enjoying our Product! Thank you for your appreciation!
-
AuthorPosts
- You must be logged in to reply to this topic.