- This topic has 10 replies, 3 voices, and was last updated 3 years, 4 months ago by
David.
-
AuthorPosts
-
December 8, 2022 at 8:55 pm #2455359
Tom
I created a Block Template (Appearance>Elements>Block)
It calls some dynamic data from Custom Fields associated with a CPT “Positions”
The Custom Fields are part of a CPT that represents various job positions (welder, fitter, etc).
I call the block template “Position Template”I then want to create a Page that I can assign the block “Position Template” to.
I then want to associate the page with a specific CPT “Position” (for example “Fitter”)On that Fitter Page – I do not know how to:
- Call the Block Template I created
- Then assign it to the CPT “Position” (Fitter)
Or am I approaching it incorrectly?
Thank you!December 8, 2022 at 10:23 pm #2455429Fernando Customer Support
Hi Tom,
I’m not understanding correctly. Are Positions – Welder, fitter, etc. Posts of your CPT or fields?
Can you clarify?
Or, so we can take a closer look at your structure, can you provide admin login credentials?:
Please use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information
December 9, 2022 at 8:12 am #2456128Tom
Fernando…
1 – Here is a link to an image that TRIES to explain what I am trying to do.
2 – I am trying to take full-advantage of Custom Post Types and ( I think) Block Templates
3 – But my approach MIGHT NOT be how Generate Press Works. (I am trying to figure it out – but am not a developer.)
4 – However – what I am doing, and I think how GP does work, would let me – not only solve my problem of displaying dynamic data on pages – with a single design – but also let me use it a myriad of other places – even landing pages down-the-road.Image Link (plus private information below):
https://imgur.com/cfhBTYVDecember 9, 2022 at 10:54 am #2456291David
StaffCustomer SupportHi there,
you need to create template files for your CPTs.
In the GeneratePress Theme folder or from the GitHubhttps://github.com/tomusborne/generatepress
1. Copy the
single.phpand thecontent-single.phpto your child theme.
2. Rename them to match your CPT slug. eg.single-{cpt_slug}.phpandcontent-{cpt_slug}.php
Swap{cpt_slug}for the slug eg.positionor whaterver your CPT slug is.
3. In yoursingle-{cpt_slug}.phpsee this line:this code:
generate_do_template_part( 'single' );swap the
singlefor your CPT slug.4. Repeat this for each of your CPTS.
5. Then in your Block Element you can select your Custom post type on the Display Rules.
December 9, 2022 at 11:18 am #2456315Tom
Gadzooks David! :^) Hopefully I can dive in later this afternoon.
Question: I do not have a Child theme – that should be the first step correct? Does Generate Press provide one? (I f not – I can make one)…
Thank you!
December 9, 2022 at 11:50 am #2456342David
StaffCustomer SupportThats correct and yes we do – read here:
https://docs.generatepress.com/article/using-child-theme/
The doc includes a link to a starter child theme zip
December 10, 2022 at 2:16 pm #2457369Tom
Downloaded and installed child theme.
Followed steps above.Still not working – but do not know if I am doing it correctly. Doesn’t seem like it should be that difficult.
CPT>Elements (Block)>Calling the block from a Page.
Nothing appears when I preview the Page other than the title.Let me know if anything jumps out. Thank you.
December 10, 2022 at 3:30 pm #2457381Tom
I *think* I figured it out.
I have the Block>Position Template appearing in the Position> All Positions location.
IN the Custom Post Type “Fitter”:
- I created a Container.
- Enabled Dynamic Data
- Data Source – Post Type
- Post Type – “Positions”
- Source Post – “#xxx:Fitter”
And when I previewed the page it worked.
The problem I was having (creating for myself) was thinking I had to CREATE a PAGE to display the information from the CPT “Fitter”.
When in fact it already existed as the Fitter Post itself.
So – In the Menu – I did not have “Positions” chosen to be visible. Chose Fitter – and it all worked.
:^)
December 11, 2022 at 6:44 am #2457781David
StaffCustomer SupportThe problem I was having (creating for myself) was thinking I had to CREATE a PAGE to display the information from the CPT “Fitter”.
Yeah i can see how that can be misunderstood 🙂
Glad to hear you got it working
December 11, 2022 at 9:38 am #2458065Tom
This is absolutely bad-A**. Love how this is working. I had two years of Drupal experience. Steep learning curve – but once you connected some concepts – it was apparent what you could do with it. GP is as close to that granular Drupal model as you can get within WordPress I would think (and still not be a developer to stretch the capabilities). Websites are a fraction of what I do now, so I have probably forgotten more than I know, but this really helps.
Thanks for your help & Fernando’s, and Ying’s!
December 12, 2022 at 4:34 am #2458794David
StaffCustomer SupportSuper glad to hear that , and we’re happy to be of help 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.